# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
250586 |
2020-07-18T12:59:27 Z |
REALITYNB |
Trol (COCI19_trol) |
C++14 |
|
1 ms |
256 KB |
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std ;
int countt(int x ){
int sum = 0 ;
while(x){
sum += x%10 ;
x/=10 ;
}
if(sum<10) return sum ;
return countt(sum) ;
}
signed main(){
int q ;
cin>> q ;
while(q--){
int l ,r ;
cin>>l>>r ;
int sum = 0 ;
if(r-l<=9){
for(int i=l;i<=r;i++) sum += countt(i) ;
cout << sum << endl ;
continue ;
}
while(countt(l)!=1){
sum += countt(l) ;
l++ ;
}
while(countt(r)!=9){
sum += countt(r) ;
r-- ;
}
sum += ((r-l+1)/9)*45 ;
cout << sum << endl ;
}
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |