Submission #135766

#TimeUsernameProblemLanguageResultExecution timeMemory
135766tdwnSequence (BOI14_sequence)C++17
0 / 100
2 ms380 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 100100; ll n, arr[maxn]; int main() { cin>>n; cin>>arr[1]; ll num = arr[1]; for(int i=2;i<=n;i++) { num++; cin>>arr[i]; ll tmp = num; bool found = false; while(tmp > 0) { if((tmp%10) == arr[i]) found = true; tmp /= 10; } if(found) continue; num--; tmp = num; int br = 0; while(tmp > 0) { tmp /= 10; br++; } ll nwnum = arr[i]; ll pw = 1LL; for(int i=0;i<br;i++) { nwnum *= 10LL; pw *= 10LL; } //cout<<i<<"A: "<<nwnum<<"\n"; nwnum += num + 1; if(arr[i-1] == 9) { nwnum -= pw; } num = nwnum; } cout<<num-n+1<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...