#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool bad[105] = {};
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int Q;
ll L, R;
cin >> Q;
while (Q--) {
cin >> L >> R;
ll ans = (R/9) * 45 + ((R%9) * (R%9 + 1)) / 2;
if (L > 1) {
L--;
ans -= (L/9) * 45 + ((L%9) * (L%9 + 1)) / 2;
}
cout << ans << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
392 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |