# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
250650 | oko | Trol (COCI19_trol) | C++14 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int num(long long x)
{
if((x%10)==x)return x;
long long y=0;
while(x)
{
y+=(x%10);
x/=10;
}
return num(y);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int t;
cin>>t;
while(t--)
{
long long l,r,sum=0,f=0,ni=(1+2+3+4+5+6+7+8+9);
cin>>l>>r;
while(true)
{
int x=num(l);
sum+=x;
if(x==9)break;
if(l==r)
{
f=1;
break;
}
l++;
}
while(true)
{
int x=num(r);
if(f||x==9)break;
sum+=x;
r--;
}
cout<<sum+(((r-l)/9)*ni)<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |