Submission #871594

# Submission time Handle Problem Language Result Execution time Memory
871594 2023-11-11T07:07:33 Z vjudge1 Trol (COCI19_trol) C++17
10 / 50
1000 ms 504 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define int i64

int calc(int x) {
    int res = 0;
    while(x) {
        res += x % 10;
        x /= 10;
    }

    return res;
}

ostream &operator<< (ostream &out, __int128_t x) {
    string res;
    while(x) {
        res += char(x % 10 + '0');
        x /= 10;
    }

    reverse(res.begin(), res.end());

    return out << res;
}

#define ONLINE_JUDGE
void solve() {
    int l, r;
    cin >> l >> r;

    __int128_t ans = 0;
    for(int i = l; i <= r; i++) {
        ans += calc(i);
    }

    cout << ans << "\n";
    
    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Incorrect 2 ms 504 KB Output isn't correct
4 Execution timed out 1092 ms 388 KB Time limit exceeded
5 Execution timed out 1068 ms 348 KB Time limit exceeded