#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int q;
cin >> q;
int a[] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45};
while(q--){
int l, r;
cin >> l >> r;
int kanan = (r / 9 * 45) + a[r%9];
l--;
int kiri = (l / 9 * 45) + a[l%9];
cout << kanan - kiri << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |