Interesting Function

#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
ll solve(int n){
    ll ans=0;
    for(int i=1;i<=10;i++)
        ans+=n/(int)(pow(10,i-1));
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    int l,r;
    int t;cin>>t;
    while(t--){
        cin>>l>>r;
        cout<<solve(r)-solve(l)<<endl;
    }
}
View Code

 

posted @ 2021-06-11 12:46  Acception  阅读(29)  评论(0)    收藏  举报