ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214391 | #2678. Small Multiple | stawalr | 100 | 6735ms | 127680kb | C++ | 1.1kb | 2024-11-18 19:44:42 | 2024-11-19 08:29:35 |
answer
#include<cstdio>
#include<queue>
#include<vector>
#include<functional>
#include<cstring>
#include<utility>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
const int mn=1e6+5,mm=1e7+5;
int k,m;
int hd[mn],to[mm],nxt[mm],w[mm],cnt=1;
int dis[mn];
bool vis[mn];
priority_queue<pii,vector<pii>,greater<pii> > q;
void add(int x,int y,int z)
{
nxt[cnt]=hd[x];
to[cnt]=y;
w[cnt]=z;
hd[x]=cnt++;
}
void dijkstra(int s)
{
dis[s]=0;
q.push(make_pair(0,s));
while(!q.empty())
{
pii t=q.top();
q.pop();
if(vis[t.se])continue;
vis[t.se]=1;
for(int i=hd[t.se];i;i=nxt[i])
{
int u=to[i];
if(dis[u]>t.fi+w[i])
{
dis[u]=t.fi+w[i];
q.push(make_pair(dis[u],u));
}
}
}
}
int main()
{
memset(dis,0x3f,sizeof(dis));
scanf("%d%d",&k,&m);
for(int i=0;i<k;i++)
{
for(int j=0;j<m;j++)
{
add(i,(i*m+j-1)%k+1,j);
}
}
dijkstra(0);
printf("%d",dis[k]);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 5000kb
input:
32 4
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 0ms
memory: 5000kb
input:
25 6
output:
5
result:
ok single line: '5'
Test #3:
score: 5
Accepted
time: 0ms
memory: 5000kb
input:
19 3
output:
2
result:
ok single line: '2'
Test #4:
score: 5
Accepted
time: 0ms
memory: 5004kb
input:
64 7
output:
4
result:
ok single line: '4'
Test #5:
score: 5
Accepted
time: 0ms
memory: 5012kb
input:
86 10
output:
3
result:
ok single line: '3'
Test #6:
score: 5
Accepted
time: 0ms
memory: 4996kb
input:
17 2
output:
2
result:
ok single line: '2'
Test #7:
score: 5
Accepted
time: 644ms
memory: 127680kb
input:
937761 10
output:
6
result:
ok single line: '6'
Test #8:
score: 5
Accepted
time: 377ms
memory: 91028kb
input:
788944 8
output:
4
result:
ok single line: '4'
Test #9:
score: 5
Accepted
time: 255ms
memory: 31972kb
input:
573314 3
output:
4
result:
ok single line: '4'
Test #10:
score: 5
Accepted
time: 725ms
memory: 63096kb
input:
785883 5
output:
2
result:
ok single line: '2'
Test #11:
score: 5
Accepted
time: 699ms
memory: 80044kb
input:
769025 7
output:
6
result:
ok single line: '6'
Test #12:
score: 5
Accepted
time: 365ms
memory: 60308kb
input:
909894 4
output:
3
result:
ok single line: '3'
Test #13:
score: 5
Accepted
time: 270ms
memory: 77816kb
input:
585472 9
output:
8
result:
ok single line: '8'
Test #14:
score: 5
Accepted
time: 314ms
memory: 59484kb
input:
795020 5
output:
4
result:
ok single line: '4'
Test #15:
score: 5
Accepted
time: 307ms
memory: 63972kb
input:
514716 8
output:
3
result:
ok single line: '3'
Test #16:
score: 5
Accepted
time: 839ms
memory: 83820kb
input:
984458 5
output:
4
result:
ok single line: '4'
Test #17:
score: 5
Accepted
time: 339ms
memory: 25192kb
input:
645285 2
output:
4
result:
ok single line: '4'
Test #18:
score: 5
Accepted
time: 321ms
memory: 89828kb
input:
694328 9
output:
8
result:
ok single line: '8'
Test #19:
score: 5
Accepted
time: 542ms
memory: 65764kb
input:
698907 6
output:
2
result:
ok single line: '2'
Test #20:
score: 5
Accepted
time: 738ms
memory: 107720kb
input:
994036 7
output:
2
result:
ok single line: '2'