Submission #972843

# Submission time Handle Problem Language Result Execution time Memory
972843 2024-05-01T09:01:41 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int Q; cin >> Q;
    while(Q--){
        ll L, R; cin >> L >> R;
        ll ans = (R/9)*45 - ((L + 8)/9)*45;
        for(int i = 1; i <= R % 9; i++) ans += i;

        ll tmp = L%9;
        if(tmp == 0) tmp = 9;
        for(int i = tmp; i <= 9; i++) ans += i;

        cout << ans << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct