#include<bits/stdc++.h>
using namespace std;
int q;
int pref[30], arr[30];
int get_range(int a, int b){
int l = (a - 1) % 9 + 1;
int r = (b - 1) % 9 + 1;
return pref[r] - pref[l-1] + 45 * ((b - a) / 9);
}
int main(){
cin >> q;
pref[0] = 0;
for (int i = 0; i < 30; i++){
arr[i] = (i - 1) % 9 + 1;
pref[i] = arr[i] + pref[i-1];
}
for (int i = 0; i < q; i++)
{
int l,r;
cin >> l >> r;
cout << get_range(l,r) << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |