#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
ll test(int x){
if (x == 0) return 0;
ll remainder = x % 9;
return (remainder == 0) ? 9 : remainder;
}
ll sumDigit(ll l, ll r){
ll sum =0;
for(ll i = l; i <=r; i++){
sum+=test(i);
}
return sum;
}
void work(){
int n; cin >> n;
for(int i = 0; i < n ; i++){
ll l,r; cin >> l >> r;
cout << sumDigit(l,r) << endl;
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int t = 1;// cin >> t;
while(t--)work();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |