#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 calc(int l, int r) {
int ret = 0;
for (int i = l; i <= r; i++){
ret += f(i);
}
return ret;
}
int main() {
for (int i = 1; i <= 100; i++) cout << f(i) << " ";
int Q;
cin >> Q;
while (Q--){
int l, r;
cin >> l >> r;
cout << calc(l,r) << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Execution timed out |
1094 ms |
348 KB |
Time limit exceeded |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |