#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back;
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int q;
cin>>q;
while(q--)
{
ll l,r;
cin>>l>>r;
ll k=l;
ll suma=0;
while(k%9!=0 && k<=r)
{
suma+=(k%9);
k++;
}
//cout<<suma<<endl;
ll m=r;
while(m>=k && m%9!=0)
{
suma+=(m%9);
m--;
}
/*cout<<suma<<endl;
cout<<m<<" "<<k<<endl;*/
if(m%9==0) suma+=9;
cout<<((m-k)/9)*45+suma<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |