#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll bil (ll n){
ll ret= (n/9)* 45;
for (int i=1; i<=n%9; i++) ret+=i;
return ret;
}
int main(){
int q;
cin >> q;
for (int i=0; i<q; i++){
ll l, r;
cin >> l >> r;
cout << bil(r) - bil(l-1) << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |