답안 #991227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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;
    }
}
# 결과 실행 시간 메모리 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