# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
208093 | dOAOb | Trol (COCI19_trol) | C++14 | 5 ms | 376 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<iostream>
using namespace std;
#define int long long
#ifdef lioraju
#define ndbg(x)
#else
#define ndbg(x) x
#endif
int f(int i)
{
if (i<10) return i;
int sum = 0;
while (i)
sum += i%10, i/=10;
return f(sum);
}
int prv(int x)
{
if (!x) return 0;
int se = 0;
for (int j=x-x%10+1;j<=x;j++)
se += f(j);
return (x/10)*45 + se + prv(x/10);
}
signed main()
{
ndbg( ios::sync_with_stdio(0); cin.tie(0); );
int q; cin>>q;
for (int qi=0; qi<q; qi++)
{
int l, r; cin>>l>>r;
cout<<prv(r)-prv(l-1)<<'\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |