Submission #3009941
Source Code Expand
/*input */ #include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; #define IOS ios_base::sync_with_stdio(0); cin.tie(0) #define ALL(a) a.begin(),a.end() #define SZ(a) ((int)a.size()) #define F first #define S second #define REP(i,n) for(int i=0;i<((int)n);i++) #define pb push_back #define MP(a,b) make_pair(a,b) #define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end())))) #define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin()) #ifdef leowang #define debug(...) do{\ fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\ _DO(__VA_ARGS__);\ }while(0) template<typename I> void _DO(I&&x){cerr<<x<<endl;} template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);} #else #define debug(...) #endif template<typename T1,typename T2> ostream& operator<<(ostream& out,pair<T1,T2> P){ out<<'('<<P.F<<','<<P.S<<')'; return out; } //}}} const ll maxn=300005; const ll maxlg=__lg(maxn)+2; const ll INF64=8000000000000000000LL; const int INF=0x3f3f3f3f; const ll MOD=ll(1e9+7); const double PI=acos(-1); //const ll p=880301; //const ll P=31; ll mypow(ll a,ll b){ ll res=1LL; while(b){ if(b&1) res=res*a%MOD; a=a*a%MOD; b>>=1; } return res; } priority_queue<pii,vector<pii>,greater<pii>> q; int ans[maxn]; int main() { int n; cin>>n; REP(i,n) ans[i]=INF; q.push(MP(1,1)); ans[1]=1; while(SZ(q)){ pii cur=q.top(); q.pop(); //cout<<cur.S<<' '<<cur.F<<'\n'; if(cur.F!=ans[cur.S]) continue; if(ans[cur.S*10%n]>cur.F){ q.push(MP(cur.F,cur.S*10%n)); ans[cur.S*10%n]=cur.F; } if(ans[(cur.S+1)%n]>cur.F+1){ q.push(MP(cur.F+1,(cur.S+1)%n)); ans[(cur.S+1)%n]=cur.F+1; } } cout<<ans[0]<<'\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Small Multiple |
User | iloveUtaha |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 2050 Byte |
Status | AC |
Exec Time | 19 ms |
Memory | 1276 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 1 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 1 ms | 256 KB |
14.txt | AC | 1 ms | 256 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | AC | 1 ms | 256 KB |
17.txt | AC | 1 ms | 256 KB |
18.txt | AC | 1 ms | 256 KB |
19.txt | AC | 1 ms | 256 KB |
20.txt | AC | 1 ms | 256 KB |
21.txt | AC | 12 ms | 768 KB |
22.txt | AC | 12 ms | 768 KB |
23.txt | AC | 15 ms | 1276 KB |
24.txt | AC | 19 ms | 1276 KB |
25.txt | AC | 14 ms | 1024 KB |
26.txt | AC | 14 ms | 1024 KB |
27.txt | AC | 16 ms | 1276 KB |
28.txt | AC | 15 ms | 1276 KB |
29.txt | AC | 16 ms | 1024 KB |
30.txt | AC | 18 ms | 1276 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 1 ms | 256 KB |
33.txt | AC | 14 ms | 1148 KB |
34.txt | AC | 6 ms | 640 KB |
35.txt | AC | 13 ms | 896 KB |
36.txt | AC | 14 ms | 1024 KB |
37.txt | AC | 5 ms | 512 KB |
38.txt | AC | 6 ms | 512 KB |
39.txt | AC | 8 ms | 640 KB |
40.txt | AC | 2 ms | 384 KB |
41.txt | AC | 12 ms | 768 KB |
42.txt | AC | 14 ms | 1024 KB |
43.txt | AC | 3 ms | 384 KB |
44.txt | AC | 2 ms | 256 KB |
45.txt | AC | 8 ms | 640 KB |
46.txt | AC | 9 ms | 672 KB |
47.txt | AC | 2 ms | 256 KB |
48.txt | AC | 12 ms | 768 KB |
49.txt | AC | 12 ms | 896 KB |
50.txt | AC | 8 ms | 640 KB |
51.txt | AC | 4 ms | 384 KB |
52.txt | AC | 7 ms | 640 KB |
53.txt | AC | 10 ms | 768 KB |
54.txt | AC | 5 ms | 512 KB |
55.txt | AC | 8 ms | 640 KB |
56.txt | AC | 10 ms | 768 KB |
57.txt | AC | 14 ms | 896 KB |
58.txt | AC | 8 ms | 640 KB |
59.txt | AC | 10 ms | 640 KB |
60.txt | AC | 8 ms | 640 KB |
61.txt | AC | 3 ms | 384 KB |
62.txt | AC | 6 ms | 512 KB |
63.txt | AC | 12 ms | 768 KB |
64.txt | AC | 12 ms | 768 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 10 ms | 640 KB |