#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int q;
cin >> q;
while(q--){
long long l, r;
cin >> l >> r;
long long res = 0;
for(long long i = l;i <= r;++i){
long long temp = i;
while(temp > 9){
long long sum = 0;
while(temp){
sum += temp % 10;
temp /= 10;
}
temp = sum;
}
res += temp;
}
cout << res << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Execution timed out |
1004 ms |
348 KB |
Time limit exceeded |
5 |
Execution timed out |
1088 ms |
456 KB |
Time limit exceeded |