답안 #380249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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";
    }
}
# 결과 실행 시간 메모리 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