#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin >> q;
auto count = [] (long long x, int p, int mod) {
if(x < p) return 0LL;
return 1 + ((x - p) / mod);
};
for(int i = 1; i <= q; i++) {
long long l, r;
cin >> l >> r;
long long ans = 0;
for(int j = 0; j < 9; j++) {
ans += (count(r, j, 9) - count(l - 1, j, 9)) * (j ? j : 9);
}
cout << ans << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |