제출 #1256103

#제출 시각아이디문제언어결과실행 시간메모리
1256103rajinnyoTrol (COCI19_trol)C++20
50 / 50
0 ms328 KiB
#include<bits/stdc++.h> using namespace std; #define int long long // JANGAN LUPA CEK PERLU LL NGGAK #define pb push_back #define miku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int mo(int x){ if(x%9) return x%9; else return 9; } signed main(){ miku int q;cin>>q; while(q--){ int l,r;cin>>l>>r; int ans=0; int cur=0; for(int i=l;;i++){ if(i>r) break; ans+=mo(i); cur=i; if(mo(i)==9) break; } cur++; int sz=(r-cur+1)/9; ans+=sz*45; if(sz) cur+=(sz*9)-1; if(sz) cur++; for(int i=cur;i<=r;i++){ ans+=mo(i); } cout<<ans<<endl; } } // very mathy
#Verdict Execution timeMemoryGrader output
Fetching results...