#include <bits/stdc++.h>
using namespace std;
int sum_of_digits(int n) {
int sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
int main() {
vector<int> baskom(61);
for (int i = 1; i <= 60; ++i) {
baskom[i] = i;
}
int Q;
cin >> Q;
for (int i = 0; i < Q; ++i) {
int L, R;
cin >> L >> R;
int total_sum = 0;
for (int j = L; j <= R; ++j) {
int current_num = baskom[j];
while (current_num > 9) {
current_num = sum_of_digits(current_num);
}
total_sum += current_num;
}
cout << total_sum << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |