Submission #975137

#TimeUsernameProblemLanguageResultExecution timeMemory
975137vjudge1Trol (COCI19_trol)C++17
50 / 50
1 ms600 KiB
#include <bits/stdc++.h>
#define ll long long

using namespace std;


int main(){
    int q; cin >> q;

    while(q--){
        ll l, r; cin >> l >> r;

        ll ansR = 0;
        ansR += (r/9) * 45;
        for(int i = 1; i <= r % 9; i++){
            ansR += i;
        }

        ll ansL = 0;
        ansL += ((l-1)/9) * 45;
        for(int i = 1; i <= (l-1) % 9; i++){
            ansL += i;
        }

        cout << ansR - ansL << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...