# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
208093 |
2020-03-10T02:21:54 Z |
dOAOb |
Trol (COCI19_trol) |
C++14 |
|
5 ms |
376 KB |
#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 |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |