ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#184783 | #2355. Digit | snow_trace | 100 | 67ms | 9856kb | C++11 | 648b | 2023-09-14 08:45:06 | 2023-09-14 12:04:52 |
answer
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >p[200005];
int dis[200005],vis[200005];
int n;
signed main(){
cin >> n;
for(int i =0;i<n;i++){
p[i].push_back({10*i%n,0}),p[i].push_back({(10*i+1)%n,1});
}memset(dis,31,sizeof(dis));
deque<int>q;dis[1] = 1;q.push_back(1);
while(!q.empty()){
int now = q.front();q.pop_front();
// cout << now << endl;
for(int i =0;i<p[now].size();i++){
int to = p[now][i].first,co = p[now][i].second;
if(dis[to] > dis[now]+co){
dis[to] = dis[now]+co;
if(!co)q.push_front(to);
else q.push_back(to);
}
}
}cout << dis[0] << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 7ms
memory: 9296kb
input:
81920
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 10
Accepted
time: 7ms
memory: 8596kb
input:
55966
output:
2
result:
ok 1 number(s): "2"
Test #3:
score: 10
Accepted
time: 7ms
memory: 9752kb
input:
92661
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: 10
Accepted
time: 8ms
memory: 8884kb
input:
68013
output:
18
result:
ok 1 number(s): "18"
Test #5:
score: 10
Accepted
time: 7ms
memory: 9032kb
input:
72927
output:
27
result:
ok 1 number(s): "27"
Test #6:
score: 10
Accepted
time: 3ms
memory: 7216kb
input:
15047
output:
5
result:
ok 1 number(s): "5"
Test #7:
score: 10
Accepted
time: 11ms
memory: 8612kb
input:
59994
output:
36
result:
ok 1 number(s): "36"
Test #8:
score: 10
Accepted
time: 11ms
memory: 9856kb
input:
97273
output:
10
result:
ok 1 number(s): "10"
Test #9:
score: 10
Accepted
time: 3ms
memory: 8368kb
input:
51139
output:
14
result:
ok 1 number(s): "14"
Test #10:
score: 10
Accepted
time: 3ms
memory: 8500kb
input:
55788
output:
15
result:
ok 1 number(s): "15"
Extra Test:
score: 0
Extra Test Passed