답안 #975622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975622 2024-05-05T15:00:33 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 352 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

int main(){
    ll q; cin >> q;
    while(q--){
        ll l , r; cin >> l >> r;
        ll tot1 = r/9, sisa1 = r%9;
        ll sum1 = tot1 * 45 + ((sisa1*(sisa1+1))/2);

        l--;
        ll tot2 = l/9, sisa2 = l%9;
        ll sum2 = tot2 * 45 + ((sisa2*(sisa2+1))/2);

        cout << sum1-sum2 << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct