#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
#define M 1000005
typedef long long ll;
int p,q;
ll ans;
ll f(ll n)
{
if(n==0)
return 0;
else if(n%10!=0)
return n%10;
else
return f(n/10);
}
void s(ll l,ll r)
{
int i;
if(r-l<9)
{
for(i=l;i<=r;i++)
{
ans+=f(i);
}
return;
}
else
{
while(l%10!=0)
{
ans+=f(l);
l++;
}
while(r%10!=0)
{
ans+=f(r);
r--;
}
ans+=45*(r-l)/10;
s(l/10,r/10);
}
}
int main()
{
while(scanf("%d%d",&p,&q)!=EOF)
{
if(p==-1&&q==-1)
break;
ans=0;
s(p,q);
printf("%lld\n",ans);
}
return 0;
}
uva 10994 - Simple Addition
最新推荐文章于 2022-04-15 15:35:58 发布