#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
long long f(long long x)
{
long long d=x/9,r=x%9;
return d*45+r*(r+1)/2;
}
void solve()
{
long long l,r;
cin>>l>>r;
cout<<f(r)-f(l-1)<<"\n";
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int qq;
cin>>qq;
while(qq--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |