# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007338 | vjudge1 | Trol (COCI19_trol) | C++17 | 1066 ms | 408 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 menghitung jumlah digit hingga menjadi satu digit
int singleDigitSum(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; // Membaca jumlah pertanyaan
for (int i = 0; i < Q; ++i) {
long long L, R;
cin >> L >> R;
long long totalSum = 0;
for (long long j = L; j <= R; ++j) {
totalSum += singleDigitSum(j);
}
cout << totalSum << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |