Submission #974669

#TimeUsernameProblemLanguageResultExecution timeMemory
974669vjudge1Trol (COCI19_trol)C++17
10 / 50
1041 ms348 KiB
#include <iostream>
#include <cmath>

using namespace std;

// Fungsi untuk menghitung jumlah digit dari suatu bilangan
int hitungJumlahDigit(long long n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int Q;
    cin >> Q;

    for (int i = 0; i < Q; ++i) {
        long long L, R;
        cin >> L >> R;

        long long total = 0;
        // Menghitung jumlah digit dari setiap bilangan dalam rentang
        for (long long j = L; j <= R; ++j) {
            total += hitungJumlahDigit(j);
        }

        cout << total << endl;
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...