#include<bits/stdc++.h>
#define lcm(a,b) (a/__gcd(a,b))*b
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define F first
#define S second
#define mp make_pair
//salida rapida "\n"
//DECIMALES fixed<<sp(n)<<x<<endl;
//gcd(a,b)= ax + by
//lCB x&-x
//set.erase(it) - ersases the element present at the required index//auto it = s.find(element)
//set.find(element) - iterator pointing to the given element if it is present else return pointer pointing to set.end()
//set.lower_bound(element) - iterator pointing to element greater than or equal to the given element
//set.upper_bound(element) - iterator pointing to element greater than the given element
// | ^
using namespace std;
int f(ll num){
while(num>9){
ll aux=num;
ll sum=0;
while(aux>0){
sum+=aux%10;
aux/=10;
}
num=sum;
}
return num;
}
int main()
{
int q,l,r;
cin>>q;
while(q--){
cin>>l>>r;
int c=r-l+1;
int in=f(l);
if(in+c-1<10){
cout<<(in+in+c-1)*(c)/2<<endl;
continue;
}
continue;
ll res=(in+9)*(9-in+1)/2;
c-=(9-in+1);
res+=(c/9)*45;
c=c%9;
res+=(1+c)*c/2;
cout<<res<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
364 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |