#include <bits/stdc++.h>
using namespace std;
long long L[107];
int main(){
long long N,x,y;
cin >> N;
for (int i=0;i<N;i++){
long long zb=45,a,ost,br,z;
cin >> x >> y;
a=x%9;
if (a==0) a=9;
z=a;
br=(y-x)/9;
ost=(y-x)%9;
for (long long j=a+1;j<a+1+ost;j++){
z+=j;
if (j>=10) z-=9;
}
z+=(br*zb);
L[i]=z;
}
for (long long i=0;i<N;i++){
if (i!=0) cout << endl;
cout << L[i];
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |