제출 #1254322

#제출 시각아이디문제언어결과실행 시간메모리
1254322warrennTrol (COCI19_trol)C++20
50 / 50
0 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long 

int com(int a){
    int hah=a%9;
    if(hah==0)hah=9;
    return hah;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int qu;
    cin>>qu;
    while(qu--){
        int l,r;
        cin>>l>>r;
        int fir=com(l);
        int sec=com(r);

        int full=(r-l+1)/9;
        int sisa=(r-l+1)-full*9;
        int ans=full*45;
        for(int q=1;q<=sisa;q++){
            ans+=com(r-q+1);
        }
        cout<<ans<<endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...