# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
975154 |
2024-05-04T13:52:19 Z |
vjudge1 |
Trol (COCI19_trol) |
C++17 |
|
1 ms |
604 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll digits ( ll y ){
ll sum = 1e18;
while ( sum >= 10 ){
sum = 0;
while ( y >= 1 ){
sum += (y % 10);
y /= 10;
}
y = sum;
}
return sum;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int q; cin >> q;
while ( q-- ){
ll l, r; cin >> l >> r;
ll now = l;
ll ans = 0;
while ( now <= r && digits ( now ) != 1 ){
ans += digits ( now );
now++;
}
ll temp = ( ( r - ( now - 1)) / 9 );
ans += ( temp * 45ll);
now += ( temp * 9);
for ( ll i = now; i <= r; i++){
ans += digits(i);
}
cout << ans << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |