답안 #231134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
231134 2020-05-12T20:41:40 Z jungsnow Trol (COCI19_trol) C++14
40 / 50
5 ms 384 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

ll L, R;

void solve() {
    cin >> L >> R;
    ll mi[9];
    for (int i = 0; i < 9; i++) mi[i] = 2e18;
    for (int i = 0; i < 10; i++) {
        ll nVal = (L + i);
        if (nVal > R) break;
        mi[nVal % 9] = min(mi[nVal % 9], nVal);
    }
    ll sum = 0;
    for (int i = 0; i < 9; i++) {
        if (mi[i] == 2e18) continue;
        //cerr<<i<<' '<<mi[i]<<'\n';
        int cnt = (R - mi[i]) / 9 + 1;
        if (i == 0) sum += 9 * cnt;
        else sum += i * cnt;
    }
    cout << sum << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int T; cin >> T; while (T--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Incorrect 5 ms 384 KB Output isn't correct