Submission #968637

#TimeUsernameProblemLanguageResultExecution timeMemory
968637VMaksimoski008Trol (COCI19_trol)C++14
20 / 50
1091 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

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

    auto query = [&](ull p) {
        if(!p) return 0ull;
        int full = p / 9;
        ull ans = full * 45;
        for(ull i=full*9+1; i<=p; i++) ans += i % 9;
        return ans;
    };

    while(q--) {
        ull l, r;
        cin >> l >> r;
        cout << query(r) - query(l-1) << '\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...