#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int q; cin >> q;
while(q--){
ll l, r; cin >> l >> r;
ll ansR = 0;
ansR += (r/9) * 45;
for(int i = 1; i <= r % 9; i++){
ansR += i;
}
ll ansL = 0;
ansL += ((l-1)/9) * 45;
for(int i = 1; i <= (l-1) % 9; i++){
ansL += i;
}
cout << ansR - ansL << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |