#include <iostream> using namespace std; void renorm(int64_t &b, int &kb){ for (int j=0; b<100000000000000000ll && kb>0; j++){ b*=10; kb--; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; int64_t acc=0; int64_t b; int kb; cin >>n; cin>>b; kb = 0; for (int i=1; i<n;i++) { int64_t a,k; cin>>a; int64_t dziel=1; b++; int64_t bb = b; k=kb; while (a<bb) { bb /=10; k++; dziel*=10; } acc += k; if (a>bb){ b=a; kb=k; renorm(b,kb); } } cout<<acc<<endl; return 0; }
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #include <iostream> using namespace std; void renorm(int64_t &b, int &kb){ for (int j=0; b<100000000000000000ll && kb>0; j++){ b*=10; kb--; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; int64_t acc=0; int64_t b; int kb; cin >>n; cin>>b; kb = 0; for (int i=1; i<n;i++) { int64_t a,k; cin>>a; int64_t dziel=1; b++; int64_t bb = b; k=kb; while (a<bb) { bb /=10; k++; dziel*=10; } acc += k; if (a>bb){ b=a; kb=k; renorm(b,kb); } } cout<<acc<<endl; return 0; } |