#include <bits/stdc++.h>
using namespace std;
long long t, l, r, ansl, ansr;
void solve(){
cin >> l >> r;
ansl = ((l - 1) / 9) * 45 + (((l - 1) % 9) * ((l - 1) % 9 + 1)) / 2;
ansr = (r / 9) * 45 + ((r % 9) * (r % 9 + 1)) / 2;
cout << ansr - ansl << "\n";
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> t;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |