Submission #208093

#TimeUsernameProblemLanguageResultExecution timeMemory
208093dOAObTrol (COCI19_trol)C++14
50 / 50
5 ms376 KiB
#include<iostream> using namespace std; #define int long long #ifdef lioraju #define ndbg(x) #else #define ndbg(x) x #endif int f(int i) { if (i<10) return i; int sum = 0; while (i) sum += i%10, i/=10; return f(sum); } int prv(int x) { if (!x) return 0; int se = 0; for (int j=x-x%10+1;j<=x;j++) se += f(j); return (x/10)*45 + se + prv(x/10); } signed main() { ndbg( ios::sync_with_stdio(0); cin.tie(0); ); int q; cin>>q; for (int qi=0; qi<q; qi++) { int l, r; cin>>l>>r; cout<<prv(r)-prv(l-1)<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...