답안 #1007335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007335 2024-06-24T15:52:09 Z vjudge1 Trol (COCI19_trol) C++17
20 / 50
1000 ms 348 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int digitSum(int num) {
    while (num >= 10) {
        int temp = 0;
        while (num > 0) {
            temp += num % 10;
            num /= 10;
        }
        num = temp;
    }
    return num;
}

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

    vector<pair<int, int>> queries(q);
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        queries[i] = {l, r};
    }

    for (int i = 0; i < q; ++i) {
        int l = queries[i].first;
        int r = queries[i].second;

        ll ans = 0;
        for (int j = l; j <= r; ++j) {
            ans += digitSum(j);
        }

        cout << ans << endl;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Execution timed out 1095 ms 348 KB Time limit exceeded
5 Incorrect 1 ms 344 KB Output isn't correct