답안 #974833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974833 2024-05-03T22:17:00 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>

#define endl '\n'
#define ll long long

using namespace std;

int sembilan[] = {9, 1, 2, 3, 4, 5, 6, 7, 8};
int q;
ll l, r;

int toDigit(ll i) {
    return sembilan[i%9];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(nullptr);
    cin >> q;
    while(q--) {
        cin >> l >> r;
        ll ans = 0;
        ans += ((r-l)/9)*45;
        r = ((r-l)%9)+l;
        for(ll i = l;i <= r; i++) {
            ans += toDigit(i);
        }
        cout << ans << endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct