#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 |