#include <bits/stdc++.h>
using namespace std;
int f(int x){
while(x>9){
int cur = x;
int sum = 0;
while(cur!=0){
sum += cur%10;
cur/=10;
}
x = sum;
}
return x;
}
int g(int l, int r){
int ans = 0;
for(int i = l; l<=r; i++){
ans+=f(i);
}
return ans;
}
int main(){
int q;
cin >> q;
while(q--){
int l,r;
cin >> l >> r;
cout << g(l,r) << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1052 ms |
348 KB |
Time limit exceeded |
2 |
Execution timed out |
1039 ms |
348 KB |
Time limit exceeded |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Execution timed out |
1090 ms |
348 KB |
Time limit exceeded |
5 |
Incorrect |
0 ms |
604 KB |
Output isn't correct |