#include <bits/stdc++.h>
using namespace std;
#define int long long
int f(int x) {
int ans = x/9;
ans *= 45;
int leftover = x%9;
ans += leftover * (leftover+1)/2;
return ans;
}
void solve() {
int l,r;cin>>l>>r;
cout << f(r) - f(l-1) << endl;
}
int32_t main() {
ios_base::sync_with_stdio(0);cin.tie(NULL);
int t;cin>>t;
while (t--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |