답안 #977187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977187 2024-05-07T13:14:07 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n' 
#define debug(x) cerr << #x << " --> " << x << endl;
#define shine ios_base::sync_with_stdio(false), cin.tie(nullptr);
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    shine
    ll q;
    cin >> q;
    while(q--){
        ll l, r;
        cin >> l >> r;
        l--;
        ll cnt1 = (r / 9), cnt2 = (l / 9), mod1 = r % 9, mod2 = l % 9;
        ll ans = 45*(cnt1 - cnt2) + ((mod1*(mod1+1)-(mod2*(mod2+1))) >> 1);
        cout << ans << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct