#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll cek(ll r){
ll ans = (r / 9) * 45;
for(ll i = 1; i <= r % 9; i++){
ans += i;
}
return ans;
}
int main(){
ll q, l, r;
cin >> q;
for(ll i = 0; i < q; i++){
cin >> l >> r;
cout << cek(r) - cek(l - 1) << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |