제출 #1172796

#제출 시각아이디문제언어결과실행 시간메모리
1172796hewfhlwejflTrol (COCI19_trol)C++20
40 / 50
0 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; for(int i=1;i<=r%9;i++) res+=i; x=(l%9); if((!x))x=9; for(int i=x;i<=9;i++) res+=i; r-=r%9; l+=9-x+1; if(l<=r)res+=(r-l+1)*45/9; cout<<res<<endl; } //for(int i=1;i<=n;i++)cout<<a[i]<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...