Submission #991227

# Submission time Handle Problem Language Result Execution time Memory
991227 2024-06-01T15:28:31 Z vjudge1 Trol (COCI19_trol) C++17
0 / 50
1000 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

int f(int x){
    while(x>9){
        int cur = x;
        int sum = 0;
        while(cur!=0){
            sum += cur%10;
            cur/=10;
        }
        x = sum;
    }
    return x;
}

int g(int l, int r){
    int ans = 0;
    for(int i = l; l<=r; i++){
        ans+=f(i);
        
    }
    return ans;
}



int main(){
    int q;
    cin >> q;
    while(q--){
        int l,r;
        cin >> l >> r;
        cout << g(l,r) << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 348 KB Time limit exceeded
2 Execution timed out 1039 ms 348 KB Time limit exceeded
3 Incorrect 0 ms 348 KB Output isn't correct
4 Execution timed out 1090 ms 348 KB Time limit exceeded
5 Incorrect 0 ms 604 KB Output isn't correct