답안 #975881

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

#define FUE(i, a, N) for(int i = a; i <= N; i++)

int Q;
ll L, R, prefr, prefl;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> Q;
    while(Q--){
        cin >> L >> R;
        prefr = R / 9 * 45;
        R %= 9;
        FUE(i, 1, R){
            prefr += i;
        }
        L--;
        prefl = L / 9 * 45;
        L %= 9;
        FUE(i, 1, L){
            prefl += i;
        }
        cout << prefr - prefl << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct