제출 #976724

#제출 시각아이디문제언어결과실행 시간메모리
976724vjudge1Trol (COCI19_trol)C++17
20 / 50
1 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
#define debug cout << "here\n";

int main()
{
    int q; cin >> q;
    while(q--){
        long long ans = 0;
        long long l,r; cin >> l >> r;
        while(l%9 != 1 && l <= r) {
            if(l%9 == 0) {
                ans += 9;
            }else 
                ans += l%9;
            l++;
        }
        while(r%9 != 0 && r > l) {
            ans += r%9;
            r--;
        }
        ans += 45 * ((r-l+1)/9);
        cout << ans << '\n';
    }
    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...