#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mid (l+r)/2
#define left 2*i+1
#define righ 2*i+2
using namespace std;
ll q;
ll l,r;
ll sum(ll x){
ll ret=(x/9)*45;
x%=9;
ret+=x*(x+1)/2;
return ret;
}
int main()
{
cin>>q;
while(q--){
cin>>l>>r;
cout<<sum(r)-sum(l-1)<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 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 |
6 ms |
256 KB |
Output is correct |