Submission #1007338

#TimeUsernameProblemLanguageResultExecution timeMemory
1007338vjudge1Trol (COCI19_trol)C++17
20 / 50
1066 ms408 KiB
#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 timeMemoryGrader output
Fetching results...