제출 #250650

#제출 시각아이디문제언어결과실행 시간메모리
250650okoTrol (COCI19_trol)C++14
50 / 50
1 ms384 KiB
#include<bits/stdc++.h> using namespace std; const long long mod=1e9+7; int num(long long x) { if((x%10)==x)return x; long long y=0; while(x) { y+=(x%10); x/=10; } return num(y); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(".in","r",stdin); //freopen(".out","w",stdout); int t; cin>>t; while(t--) { long long l,r,sum=0,f=0,ni=(1+2+3+4+5+6+7+8+9); cin>>l>>r; while(true) { int x=num(l); sum+=x; if(x==9)break; if(l==r) { f=1; break; } l++; } while(true) { int x=num(r); if(f||x==9)break; sum+=x; r--; } cout<<sum+(((r-l)/9)*ni)<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...