답안 #976016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976016 2024-05-06T05:07:56 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll cek(ll r){
    ll ans = (r / 9) * 45;
    for(ll i = 1; i <= r % 9; i++){
        ans += i;
    }
    return ans;
}

int main(){
    ll q, l, r;
    cin >> q;
    for(ll i = 0; i < q; i++){
        cin >> l >> r;
        cout << cek(r) - cek(l - 1) << endl;
    }
    return 0;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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