您的位置:首页 > 其它

HDU--4722

2013-09-15 20:55 204 查看
题目:

Good Numbers

原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722

分析:找规律,每十个数中有一个。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define maxn 100005
#define LL __int64
int main()
{
int T,cas=1;
cin>>T;
LL l,r;
while(T--)
{
scanf("%I64d%I64d",&l,&r);
LL ll=l,rr=r;
LL cnt1=0,cnt2=0;
LL m1=l%10,m2=r%10;
LL tmp1=l/10,tmp2=r/10;
LL t1=(l-m1-1)/10,t2=(r-m2-1)/10;
if(l==m1)t1=-1;
if(r==m2)t2=-1;
t1++,t2++;
while(tmp1)
{
cnt1+=tmp1%10;
tmp1/=10;
}
while(tmp2)
{
cnt2+=tmp2%10;
tmp2/=10;
}
for(LL i=0;i<=m1;i++)
{
if((cnt1+i)%10==0)t1++;
}
for(LL i=0;i<=m2;i++)
{
if((cnt2+i)%10==0)t2++;
}
LL cnt=0;
while(l)
{
cnt+=l%10;
l/=10;
}
if(cnt%10==0)t2++;a
printf("Case #%d: %I64d\n",cas++,t2-t1);
}
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: