Submission #1172780

#TimeUsernameProblemLanguageResultExecution timeMemory
1172780hewfhlwejflTrol (COCI19_trol)C++20
10 / 50
1095 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pll pair<long long, long long> #define ppl pair<pll, long long> #define ll long long #define se second #define fi first #define pb push_back ll T,n,nq,a[1001009],m,p,cyc,cmp,k,b[1001009],bn,r,res,y,vis1[4000009],vis[4000009],x,ma[400009],l; string s,s1[9],t; vector<ll>re; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>T; while(T--) { cin>>l>>r; if(r-l+1<=20) { res=0; for(int i=l;i<=r;i++) { res+=i%9; if(i%9==0)res+=9; } cout<<res<<endl; continue; } res=0; res+=(r-l+1)/9; res*=45; for(int i=1;i<=r%9;i++) { res+=i; } x=(l%9); if((!x))x=9; y=l+9-x; if(!y)y=9; for(int i=x;i<=y;i++) res+=i; cout<<res<<endl; } //for(int i=1;i<=n;i++)cout<<a[i]<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...