Submission #1253683

#TimeUsernameProblemLanguageResultExecution timeMemory
1253683iq500Trol (COCI19_trol)C++20
50 / 50
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--){ unsigned long long int l, r, ttl=0, ans=0, bas, son, sol, sag; cin>>l>>r; ttl=r-l+1; if(ttl>9){ ans+=(ttl/9)*45; int count=0; bas=l%9; if(bas==0) bas=9; if(bas!=1){ for(unsigned long long int i=bas; i%9!=1; i++){ ans+=i; count++; } } son=r%9; //if(son==0) son=9; if(son!=0){ int modded=r%9; if(modded==0) modded=9; for(unsigned long long int i=son; i%9!=0; i--){ ans+=i; count++; } } if(count>=9) ans-=45; } else{ while(l<=r){ ans+=l%9; if(l%9==0) ans+=9; l++; } } cout<<ans<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...