Submission #1254666

#TimeUsernameProblemLanguageResultExecution timeMemory
1254666maseweraTrol (COCI19_trol)C++20
50 / 50
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int t; cin>>t; while(t--) { int final=0,h,l,r,a,b; cin>>l>>r; h=r-l; b=(r-1)%9+1; a=(l-1)%9+1; if(h/10 > 1) { h=h-9+a-b; final+=(h/9)*45; final+=(b+1)*b/2; final+=45-((a-1)*(a)/2); } else { h++; while(h--) { final+=a; a++; if(a%10==0) a=1; } } cout<<final<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...