# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
485714 |
2021-11-09T06:06:55 Z |
tato |
Trol (COCI19_trol) |
C++14 |
|
1 ms |
204 KB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll back(ll a)
{
ll cnt=0;
while(a>0)
{
cnt+=(a%10);
a=a/10;
}
if(cnt>9)
return back(cnt);
else
return cnt;
}
int main()
{
int t;
cin>>t;
int b[12];
b[0]=0;
for(int i=1; i<=11; i++)
b[i]=b[i-1]+i;
while(t--)
{
ll l,r;
cin>>l>>r;
ll cnt=0;
cnt=back(l);
ll cnt1=back(r);
if(cnt%9==0)
{
ll x=r-l;
cnt=45*(x/9)+b[x%9]+cnt;
}
else
{
ll y=9-cnt;
ll x=r-l;
if(x>y)
{
x-=y;
cnt=45*(x/9)+b[x%9]+(b[9]-b[cnt-1])+cnt;
}
else
cnt=b[cnt1]-b[cnt-1];
}
cout<<cnt<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |