ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214382 | #2678. Small Multiple | Filberte | 80 | 5052ms | 266428kb | C++11 | 1.3kb | 2024-11-18 19:16:56 | 2024-11-19 08:28:36 |
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e6 + 100;
namespace dijkstra{
vector<pair<int, ll>> g[N];
bool vis[N];
ll dis[N];
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
ll Dij(int s, int t){
memset(dis, 0x3f, sizeof(dis));
memset(vis, 0, sizeof(vis));
ll _unr = dis[0];
dis[s] = 0;
q.push(make_pair(dis[s], s));
while(!q.empty()){
int u = q.top().second;q.pop();
if(vis[u]) continue;
vis[u] = 1;
for(int i = 0;i < (int)g[u].size();i++){
int v = g[u][i].first, w = g[u][i].second;
if(dis[u] + w < dis[v]){
dis[v] = dis[u] + w;
q.push(make_pair(dis[v], v));
}
}
}
return dis[t];
}
}
using namespace dijkstra;
int n, m;
int main(){
cin >> n >> m;
for(int x = 1;x < n;x++){
for(int r = 0;r < m;r++){
int u = x, v = (x * m + r) % n;
g[u].push_back({v, r});
}
}
int s = n;
for(int r = 1;r < m;r++) g[s].push_back({r, r});
ll ans = Dij(s, 0);
cout << ans << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 8ms
memory: 65696kb
input:
32 4
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 12ms
memory: 65696kb
input:
25 6
output:
5
result:
ok single line: '5'
Test #3:
score: 5
Accepted
time: 7ms
memory: 65696kb
input:
19 3
output:
2
result:
ok single line: '2'
Test #4:
score: 5
Accepted
time: 11ms
memory: 65700kb
input:
64 7
output:
4
result:
ok single line: '4'
Test #5:
score: 5
Accepted
time: 11ms
memory: 65724kb
input:
86 10
output:
3
result:
ok single line: '3'
Test #6:
score: 5
Accepted
time: 12ms
memory: 65696kb
input:
17 2
output:
2
result:
ok single line: '2'
Test #7:
score: 0
Time Limit Exceeded
input:
937761 10
output:
6
result:
Test #8:
score: 5
Accepted
time: 580ms
memory: 192944kb
input:
788944 8
output:
4
result:
ok single line: '4'
Test #9:
score: 5
Accepted
time: 332ms
memory: 118668kb
input:
573314 3
output:
4
result:
ok single line: '4'
Test #10:
score: 0
Time Limit Exceeded
input:
785883 5
output:
2
result:
Test #11:
score: 5
Accepted
time: 714ms
memory: 190144kb
input:
769025 7
output:
6
result:
ok single line: '6'
Test #12:
score: 5
Accepted
time: 498ms
memory: 153084kb
input:
909894 4
output:
3
result:
ok single line: '3'
Test #13:
score: 5
Accepted
time: 415ms
memory: 237520kb
input:
585472 9
output:
8
result:
ok single line: '8'
Test #14:
score: 5
Accepted
time: 534ms
memory: 185680kb
input:
795020 5
output:
4
result:
ok single line: '4'
Test #15:
score: 5
Accepted
time: 466ms
memory: 154380kb
input:
514716 8
output:
3
result:
ok single line: '3'
Test #16:
score: 0
Time Limit Exceeded
input:
984458 5
output:
4
result:
Test #17:
score: 5
Accepted
time: 353ms
memory: 99936kb
input:
645285 2
output:
4
result:
ok single line: '4'
Test #18:
score: 5
Accepted
time: 551ms
memory: 266428kb
input:
694328 9
output:
8
result:
ok single line: '8'
Test #19:
score: 5
Accepted
time: 548ms
memory: 180284kb
input:
698907 6
output:
2
result:
ok single line: '2'
Test #20:
score: 0
Time Limit Exceeded
input:
994036 7