답안 #974702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974702 2024-05-03T16:19:33 Z vjudge1 Trol (COCI19_trol) C++14
50 / 50
1 ms 348 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 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