#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
// 1-9=45
// 1-18=90
ll l,r;
ll solve(ll n){
ll count,x,idx,sum=0;
idx=n%9+1;
while(idx--)sum+=idx;
count=n/9;
x= 45*count+sum;
return x;
}
int main(){
ios
ll t; cin >> t;
while (t--){
cin >> l >> r;
cout << solve(r)-solve(l-1);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
0 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 |
1 ms |
348 KB |
Output isn't correct |