#include <iostream>
using namespace std;
int calculateSum(int n) {
int sum = n;
while (sum >= 10) {
int temp = sum;
sum = 0;
while (temp > 0) {
sum += temp % 10;
temp /= 10;
}
}
return sum;
}
int main() {
int Q;
cin >> Q;
int bowls[260261];
for (int i = 1; i <= 260260; i++) {
bowls[i] = calculateSum(i);
}
for (int q = 0; q < Q; q++) {
int L, R;
cin >> L >> R;
int sum = 0;
for (int i = L; i <= R; i++) {
sum += bowls[i];
}
cout << sum << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
1372 KB |
Output is correct |
2 |
Runtime error |
4 ms |
2396 KB |
Execution killed with signal 11 |
3 |
Incorrect |
3 ms |
1372 KB |
Output isn't correct |
4 |
Runtime error |
5 ms |
2476 KB |
Execution killed with signal 11 |
5 |
Incorrect |
3 ms |
1372 KB |
Output isn't correct |