Submission #380249

# Submission time Handle Problem Language Result Execution time Memory
380249 2021-03-20T17:09:24 Z rqi Trol (COCI19_trol) C++14
50 / 50
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll red(ll a){
    if(a % 9 == 0) return 9;
    return a % 9;
}

int main(){
    int Q;
    cin >> Q;
    for(int i = 1; i <= Q; i++){
        ll l, r;
        cin >> l >> r;
        ll ans = 0;
        while(l % 9 != (r+1) % 9){
            ans+=red(l);
            l++;
        }
        ans+=(r-l+1)/9*45;
        cout << ans << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct