제출 #1255109

#제출 시각아이디문제언어결과실행 시간메모리
1255109opituTrol (COCI19_trol)C++20
40 / 50
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<int> a = {9, 1, 2, 3, 4, 5, 6, 7, 8};
    vector<int> p(10, 0), s(10, 0);
    for (int i = 1; i <= 9; i++) p[i] = p[i-1] + a[i-1];
    for (int i = 8; i >= 0; i--) s[i] = s[i+1] + a[i];
    int t; cin >> t; while (t--) {
        long long l, r; cin >> l >> r;
        int gap = r/9-(l+8)/9;
        int ans = 45*gap;
        cout << s[l%9]%45 + ans + p[r%9+1] << '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...