Submission #975357

# Submission time Handle Problem Language Result Execution time Memory
975357 2024-05-05T02:56:04 Z vjudge1 Trol (COCI19_trol) C++17
10 / 50
1000 ms 424 KB
#include <iostream>
using namespace std;

int 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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Execution timed out 1085 ms 424 KB Time limit exceeded
5 Incorrect 1 ms 348 KB Output isn't correct