#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int ntest;
for (cin >> ntest; ntest --;) {
long long l, r;
cin >> l >> r;
auto f = [&](long long x) {
long long numBlock = x / 9;
int rem = x - numBlock * 9;
return numBlock * 45 + (rem + 1) * rem / 2;
};
cout << f(r) - f(l-1) << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
252 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |