#include <iostream>
#define int long long
using namespace std;
signed main() {
int q;
cin >> q;
while (q--) {
int ans = 0;
int l, r;
cin >> l >> r;
for (int i = l; i <= r; i++) {
int x = i;
// Hitung penjumlahan digit sampai menjadi 1 digit
while (x > 10) {
int sum = 0;
while (x > 0) {
sum += (x % 10);
x /= 10;
}
x = sum;
}
ans += x;
}
cout << ans << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
4 |
Execution timed out |
1094 ms |
420 KB |
Time limit exceeded |
5 |
Execution timed out |
1073 ms |
348 KB |
Time limit exceeded |