#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans(ll x){
ll res = x / 9ll * (45ll);
ll ost = x % 9;
for (ll i = 1; i <= ost; i++)
res += i;
return res;
}
int main(){
int qq; cin >> qq;
for (; qq; qq--){
ll l, r;
cin >> l >> r;
cout << ans(r) - ans(l - 1) << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |