제출 #1253494

#제출 시각아이디문제언어결과실행 시간메모리
1253494iq500Trol (COCI19_trol)C++20
0 / 50
0 ms328 KiB
#include <bits/stdc++.h>

using namespace std;


int main() {
    int t; cin>>t;
    while(t--){
    //for(int i=1998; i<2019; i++) cout<<i<<" ";
    unsigned long long int l, r, ttl=0, ans=0, bas, son; cin>>l>>r;
    ttl=r-l+1;
    ans+=(ttl/9)*45;
    if(ttl>9){
        bas=l%9;
        if(bas==0) bas=9;
        for(int i=bas; i<=9; i++){
            ans+=i;
        }
        son=r%9;
        if(son==0) son=9;
        for(int i=son; i>=1; i--){
            ans+=i;
        }
    }
    else{
        while(l<=r){
            ans+=l%9;
            if(l%9==0) ans+=9;
            l++;
        }
    }
    cout<<ans<<"\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...