#include<bits/stdc++.h> using namespace std; const long long z=100000000000000000; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long wynik=0, ost=0, a, b; int n, liczbazer=0; cin>>n; for(int i=0; i<n; i++){ cin>>a; b=a; a++; while(a<=ost+1){ a*=10; b*=10; wynik++; } wynik+=liczbazer; if(liczbazer==0){ ost=max(b, ost+1); } else{ ost=max(b, ost); } if(ost>z){ ost/=10; liczbazer++; } //cout<<" "<<ost<<" "<<liczbazer<<" "<<wynik<<"\n"; } cout<<wynik; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include<bits/stdc++.h> using namespace std; const long long z=100000000000000000; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long wynik=0, ost=0, a, b; int n, liczbazer=0; cin>>n; for(int i=0; i<n; i++){ cin>>a; b=a; a++; while(a<=ost+1){ a*=10; b*=10; wynik++; } wynik+=liczbazer; if(liczbazer==0){ ost=max(b, ost+1); } else{ ost=max(b, ost); } if(ost>z){ ost/=10; liczbazer++; } //cout<<" "<<ost<<" "<<liczbazer<<" "<<wynik<<"\n"; } cout<<wynik; } |