#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pll pair<long long, long long>
#define ppl pair<pll, long long>
#define ll long long
#define se second
#define fi first
#define pb push_back
ll T,n,nq,a[1001009],m,p,cyc,cmp,k,b[1001009],bn,r,res,y,vis1[4000009],vis[4000009],x,ma[400009],l;
string s,s1[9],t;
vector<ll>re;
vector<ll>g[100009],cc[100009];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("paintbarn.in", "r", stdin);
	//freopen("paintbarn.out", "w", stdout);
	//freopen("cereal.in", "r", stdin);
	//freopen("cereal.out", "w", stdout);
	cin>>T;
	while(T--)
    {
        cin>>l>>r;
        res=0;
        res+=(r-l+1)/9;
        res*=45;
        for(int i=0;i<(r-l+1)%9;i++)
        {
            if(!((l+i)%9))res+=9;
            else  res+=(l+i)%9;
        }
        cout<<res<<endl;
    }
    //for(int i=1;i<=n;i++)cout<<a[i]<<endl;
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |