답안 #977160

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977160 2024-05-07T12:44:41 Z vjudge1 Trol (COCI19_trol) C++17
30 / 50
1000 ms 348 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

int num(int n){
    if (n < 9)
        return n;
    if (n % 9 == 0)
        return 9;
    return n % 9 ;
}

int f(int a, int b){
    int result = 0,  len = b - a + 1;
    a = num(a);
    while (len--){
        if (a > 9)
            a %= 9;
        result += a;
        a++;
    }
    return result;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t; cin >> t;
    while(t--){
        int a, b; cin >> a >> b;
        cout << f(a, b) << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Execution timed out 1056 ms 348 KB Time limit exceeded
5 Execution timed out 1026 ms 344 KB Time limit exceeded