#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int T;
cin>>T;
while(T--) {
ll l,r;
cin>>l>>r;
ll ans=0;
//0 1 2 3 4 5 6 7 8
while(l<=r && l%9!=0) {
ans+=(l%9==0?9:l%9);
l++;
}
while(l<=r && r%9!=8) {
ans+=(r%9==0?9:r%9);
r--;
}
ans+=(r-l+1)*5;
cout<<ans<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
364 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
380 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |