제출 #974702

#제출 시각아이디문제언어결과실행 시간메모리
974702vjudge1Trol (COCI19_trol)C++14
50 / 50
1 ms348 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll get_range(ll l, ll r) {
    l--;
    ll a = (l/ 9) * 45;
    ll b = (r / 9) * 45;
    for (int i = 1; i <= l % 9; i++) a += i;
    for (int i = 1; i <= r % 9; i++) b += i;
    return b - a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int q;
    cin >> q;
    while (q--) {
        ll l, r;
        cin >> l >> r;
        cout << get_range(l,r) << '\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...