Submission #975862

# Submission time Handle Problem Language Result Execution time Memory
975862 2024-05-06T01:25:31 Z vjudge1 Trol (COCI19_trol) C++17
20 / 50
1000 ms 600 KB
#include <iostream>
#include <vector>
using namespace std;

int digitSum(int x) {
    int sum = 0;
    while (x > 0) {
        sum += x % 10;
        x /= 10;
    }
    if (sum >= 10) {
        return digitSum(sum);
    }
    return sum;
}

int main() {
    int q;
    cin >> q;
    
    vector<int> answers;
    
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        
        int sum = 0;
        for (int j = l; j <= r; ++j) {
            sum += digitSum(j);
        }
        
        answers.push_back(sum);
    }
    
    for (int ans : answers) {
        cout << ans << endl;
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Execution timed out 1087 ms 348 KB Time limit exceeded
5 Incorrect 1 ms 600 KB Output isn't correct