Submission #976389

# Submission time Handle Problem Language Result Execution time Memory
976389 2024-05-06T13:55:16 Z vjudge1 Trol (COCI19_trol) C++17
30 / 50
1000 ms 404 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

ll sudigi(ll x, ll ret){
    if(x < 10){
        ret += x;
        return ret;
    } 

    return sudigi(x/10, (x%10) + ret);
}

int main(){
    ll q; cin >> q;
    while(q--){
        ll ans = 0;
        ll a, b; cin >> a >> b;
        for(ll i = a; i <= b; i++){
            ll total = i;
            while(total > 9){
                total = sudigi(total, 0);
            }
            ans += total;
        }
        cout << ans << endl;
    }
}
# 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 Correct 2 ms 348 KB Output is correct
4 Execution timed out 1060 ms 404 KB Time limit exceeded
5 Execution timed out 1044 ms 348 KB Time limit exceeded