#include <bits/stdc++.h>
#define int long long
using namespace std;
int digitcalc(int n){
int ret = 0;
while(n!=0){
ret += n%10;
n/=10;
}
return ret;
}
signed main (){
int q; cin >> q;
for(int i = 0;i<q;i++){
int l,r; cin >> l >> r;
int prefr = 45*(r/9) + ((r%9) * ((r%9) + 1))/2;
l--;
int prefl = 45*(l/9) + ((l%9) * ((l%9) + 1))/2;
cout << prefr - prefl << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |