ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214422 | #2678. Small Multiple | sean1381 | 100 | 112ms | 9756kb | C++11 | 454b | 2024-11-18 20:55:14 | 2024-11-19 08:33:44 |
answer
#include<bits/stdc++.h>
using namespace std;
bool vis[1000010];
int k,m,now,ans;
deque< pair<int,int> > q;
int main(){
cin>>k>>m;
q.push_back(make_pair(1,1));
while(!q.empty()){
now=q.front().first;
ans=q.front().second;
q.pop_front();
if(!now){
cout<<ans<<endl;
break;
}
if(vis[now])continue;
vis[now]=true;
q.push_front(make_pair((now*m)%k,ans));
q.push_back(make_pair((now+1)%k,ans+1));
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1240kb
input:
32 4
output:
1
result:
ok single line: '1'
Test #2:
score: 5
Accepted
time: 0ms
memory: 1240kb
input:
25 6
output:
5
result:
ok single line: '5'
Test #3:
score: 5
Accepted
time: 0ms
memory: 1240kb
input:
19 3
output:
2
result:
ok single line: '2'
Test #4:
score: 5
Accepted
time: 0ms
memory: 1244kb
input:
64 7
output:
4
result:
ok single line: '4'
Test #5:
score: 5
Accepted
time: 0ms
memory: 1244kb
input:
86 10
output:
3
result:
ok single line: '3'
Test #6:
score: 5
Accepted
time: 0ms
memory: 1244kb
input:
17 2
output:
2
result:
ok single line: '2'
Test #7:
score: 5
Accepted
time: 14ms
memory: 4900kb
input:
937761 10
output:
6
result:
ok single line: '6'
Test #8:
score: 5
Accepted
time: 0ms
memory: 2668kb
input:
788944 8
output:
4
result:
ok single line: '4'
Test #9:
score: 5
Accepted
time: 6ms
memory: 6044kb
input:
573314 3
output:
4
result:
ok single line: '4'
Test #10:
score: 5
Accepted
time: 11ms
memory: 7688kb
input:
785883 5
output:
2
result:
ok single line: '2'
Test #11:
score: 5
Accepted
time: 9ms
memory: 5856kb
input:
769025 7
output:
6
result:
ok single line: '6'
Test #12:
score: 5
Accepted
time: 4ms
memory: 4660kb
input:
909894 4
output:
3
result:
ok single line: '3'
Test #13:
score: 5
Accepted
time: 12ms
memory: 2992kb
input:
585472 9
output:
8
result:
ok single line: '8'
Test #14:
score: 5
Accepted
time: 0ms
memory: 2280kb
input:
795020 5
output:
4
result:
ok single line: '4'
Test #15:
score: 5
Accepted
time: 1ms
memory: 2796kb
input:
514716 8
output:
3
result:
ok single line: '3'
Test #16:
score: 5
Accepted
time: 21ms
memory: 9756kb
input:
984458 5
output:
4
result:
ok single line: '4'
Test #17:
score: 5
Accepted
time: 14ms
memory: 5976kb
input:
645285 2
output:
4
result:
ok single line: '4'
Test #18:
score: 5
Accepted
time: 8ms
memory: 3288kb
input:
694328 9
output:
8
result:
ok single line: '8'
Test #19:
score: 5
Accepted
time: 6ms
memory: 3816kb
input:
698907 6
output:
2
result:
ok single line: '2'
Test #20:
score: 5
Accepted
time: 6ms
memory: 7224kb
input:
994036 7
output:
2
result:
ok single line: '2'