#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define FUE(i, a, N) for(int i = a; i <= N; i++)
int Q;
ll L, R, prefr, prefl;
int main(){
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> Q;
while(Q--){
cin >> L >> R;
prefr = R / 9 * 45;
R %= 9;
FUE(i, 1, R){
prefr += i;
}
L--;
prefl = L / 9 * 45;
L %= 9;
FUE(i, 1, L){
prefl += i;
}
cout << prefr - prefl << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |