Submission #1084401

#TimeUsernameProblemLanguageResultExecution timeMemory
1084401laureTrol (COCI19_trol)C++17
50 / 50
1 ms424 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int mod=1e9+7; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q; cin>>q; while(q--) { int l,r,ans=0; cin>>l>>r; int x=l; while(x/10!=0) { int y=x; x=0; while(y>0) { x+=y%10; y/=10; } } int z=r; while(z/10!=0) { int y=z; z=0; while(y>0) { z+=y%10; y/=10; } } ans=((r-l-(9-x)-z)/9)*45; ans+=45-(x*(x-1))/2; ans+=(z*(z+1))/2; cout<<ans<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...