Submission #977163

# Submission time Handle Problem Language Result Execution time Memory
977163 2024-05-07T12:47:25 Z vjudge1 Trol (COCI19_trol) C++11
30 / 50
1000 ms 424 KB
#include <bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int dig(ll i){
   
    while(i>9){
        ll nilai=i, jdg=0;
        while(nilai!=0){
            jdg+=nilai%10;
            nilai/=10;
        }
       
        i= jdg;
    }
    return i;
    
}

int jumlah(ll p,ll r){
    ll jum=0;
    for(ll i=p; i<= r; i++){
        jum+=dig(i);
    }
    return jum;
}


int main(){
fastio;
    ll q;
    cin>>q;
    
    while(q--){
        ll p, r;
        cin>>p>>r;
        cout<<jumlah(p, r)<<endl;
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Execution timed out 1094 ms 424 KB Time limit exceeded
5 Execution timed out 1052 ms 348 KB Time limit exceeded