#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int q;
cin>>q;
while(q--){
int l,r;
cin>>l>>r;
int kali=(r-l+1)/9;
int sisa=(r-l+1)-(kali*9);
int mulai=l%9;
if(mulai==0){
mulai=9;
}
int ans=kali*45;
for(int k=1;k<=sisa;k++){
ans+=mulai;
mulai++;
if(mulai>9){
mulai=1;
}
}
cout<<ans<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
344 KB |
Output is correct |