#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int q;
cin >> q;
auto Q = [&](int p) {
if(!p) return 0ll;
int full = p / 9;
ll ans = full * 45;
for(int i=full*9+1; i<=p; i++) ans += i % 9;
return ans;
};
while(q--) {
int l, r;
cin >> l >> r;
cout << Q(r) - Q(l-1) << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |