Submission #976636

#TimeUsernameProblemLanguageResultExecution timeMemory
976636vjudge1Trol (COCI19_trol)C++17
30 / 50
1032 ms408 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ll q;cin >> q;
    while (q--) {
        ll l, r; cin >> l >> r;
        ll ans = 0;
        for (ll i=l;i<=r;i++) {
            bool cek = true;
            ll x = i;
            while (cek) {
                ll temp = 0;
                while(x>0) {
                    temp+=x%10;
                    x/=10;
                }
                x = temp;
                if (x<10) cek = false;
            }
            ans+=x;
        }
        cout << ans << endl;
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...