Submission #1266437

#TimeUsernameProblemLanguageResultExecution timeMemory
1266437canhnam357Trol (COCI19_trol)C++20
50 / 50
1 ms324 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int q;
    cin >> q;
    while (q--) {
        long long l, r;
        cin >> l >> r;
        auto f = [&](long long n) {
            int ans = 0;
            while (n % 9) {
                ans += n % 9;
                n--;
            }
            return ans + n * 5;
        };
        cout << f(r) - f(l - 1) << '\n';
    }
    return 0;
}   
#Verdict Execution timeMemoryGrader output
Fetching results...