# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976002 | vjudge1 | Trol (COCI19_trol) | C++17 | 1099 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
// Fungsi untuk mengubah bilangan menjadi bilangan dengan satu digit
int satuDigit(int n) {
while (n >= 10) {
int sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
n = sum;
}
return n;
}
int main() {
int Q;
cin >> Q;
for (int i = 0; i < Q; ++i) {
long long L, R;
cin >> L >> R;
long long total = 0;
for (long long j = L; j <= R; ++j) {
total += satuDigit(j);
}
cout << total << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |