Submission #8412626
Source Code Expand
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; using ll=long long; using datas=pair<ll,ll>; using ddatas=pair<double,double>; using tdata=pair<ll,datas>; using vec=vector<ll>; using mat=vector<vec>; using pvec=vector<datas>; using pmat=vector<pvec>; #define For(i,a,b) for(i=a;i<(ll)b;i++) #define bFor(i,a,b) for(i=a;i>=(ll)b;i--) #define rep(i,N) For(i,0,N) #define rep1(i,N) For(i,1,N) #define brep(i,N) bFor(i,N-1,0) #define all(v) (v).begin(),(v).end() #define allr(v) (v).rbegin(),(v).rend() #define vsort(v) sort(all(v)) #define vrsort(v) sort(allr(v)) #define endl "\n" #define pb push_back #define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0) const ll mod=1000000007; const ll inf=1LL<<60; template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} double distance(ddatas& x,ddatas& y){ double a=x.first-y.first,b=x.second-y.second; return sqrt(a*a+b*b); } ll modinv(ll a) { ll b=mod,u=1,v=0,t; while(b){ t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); } return (u+mod)%mod; } ll moddevide(ll a,ll b){return (a*modinv(b))%mod;} vec modncrlistp,modncrlistm; ll modncr(ll n,ll r){ ll i,size=modncrlistp.size(); if(size<=n){ modncrlistp.resize(n+1); modncrlistm.resize(n+1); if(!size){ modncrlistp[0]=modncrlistm[0]=1; size++; } For(i,size,n+1){ modncrlistp[i]=modncrlistp[i-1]*i%mod; modncrlistm[i]=modinv(modncrlistp[i]); } } return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod; } ll modpow(ll a,ll n){ ll res=1; while(n){ if(n&1)res=res*a%mod; a=a*a%mod; n>>=1; } return res; } ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);} ll lcm(ll a,ll b){return a/gcd(a,b)*b;} ll countdigits(ll n){ ll ans=0; while(n){n/=10;ans++;} return ans; } ll sumdigits(ll n){ ll ans=0; while(n){ans+=n%10;n/=10;} return ans; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N,p; cin>>N; vec v(N,inf); priority_queue<datas,pvec,greater<datas>> que; que.push(datas(1,1)); while(v[0]==inf){ auto x=que.top();que.pop(); if(v[x.second]!=inf)continue; v[x.second]=x.first; p=x.second*10%N; if(v[p]==inf)que.push(datas(x.first,p)); p=(x.second+1)%N; if(v[p]==inf)que.push(datas(x.first+1,p)); } cout<<v[0]<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Small Multiple |
User | kiyoshi0205 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 2585 Byte |
Status | AC |
Exec Time | 21 ms |
Memory | 2168 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 | 2 ms | 1024 KB |
22.txt | AC | 19 ms | 1280 KB |
23.txt | AC | 14 ms | 2168 KB |
24.txt | AC | 17 ms | 2168 KB |
25.txt | AC | 15 ms | 1660 KB |
26.txt | AC | 7 ms | 1660 KB |
27.txt | AC | 16 ms | 2168 KB |
28.txt | AC | 10 ms | 2168 KB |
29.txt | AC | 11 ms | 1660 KB |
30.txt | AC | 21 ms | 2168 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 1 ms | 256 KB |
33.txt | AC | 12 ms | 2040 KB |
34.txt | AC | 4 ms | 896 KB |
35.txt | AC | 12 ms | 1912 KB |
36.txt | AC | 7 ms | 1660 KB |
37.txt | AC | 5 ms | 768 KB |
38.txt | AC | 3 ms | 640 KB |
39.txt | AC | 5 ms | 1024 KB |
40.txt | AC | 2 ms | 384 KB |
41.txt | AC | 5 ms | 1280 KB |
42.txt | AC | 19 ms | 1660 KB |
43.txt | AC | 4 ms | 512 KB |
44.txt | AC | 2 ms | 384 KB |
45.txt | AC | 8 ms | 1024 KB |
46.txt | AC | 13 ms | 1152 KB |
47.txt | AC | 2 ms | 384 KB |
48.txt | AC | 15 ms | 1408 KB |
49.txt | AC | 16 ms | 1532 KB |
50.txt | AC | 10 ms | 1024 KB |
51.txt | AC | 5 ms | 640 KB |
52.txt | AC | 9 ms | 1024 KB |
53.txt | AC | 14 ms | 1152 KB |
54.txt | AC | 7 ms | 768 KB |
55.txt | AC | 11 ms | 1024 KB |
56.txt | AC | 12 ms | 1152 KB |
57.txt | AC | 20 ms | 1660 KB |
58.txt | AC | 13 ms | 1024 KB |
59.txt | AC | 17 ms | 1280 KB |
60.txt | AC | 14 ms | 1024 KB |
61.txt | AC | 4 ms | 512 KB |
62.txt | AC | 10 ms | 768 KB |
63.txt | AC | 17 ms | 1280 KB |
64.txt | AC | 19 ms | 1280 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 15 ms | 1152 KB |