题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=2089
用求余取末尾俩位看是否是62,一位是否是4。循环判断,一直到数字判断完,要注意,,n与m的大小,输入不确定,需要进行俩者换值。
#include<stdio.h>
int no_4and62(long n)
{
while(n)
{
if(n%10==4||n%100==62)
return 0;
n=n/10;
}
return 1;
}
int a[1000001]= {0};
long n,m,i;
int main()
{
for(i=1; i<1000001; i++)
a[i]=a[i-1]+no_4and62(i);
while(scanf("%ld%ld",&n,&m)!=EOF)
{
if(n==0&&m==0)
break;
if(n>m)
{
int ter=n;
n=m;
m=ter;
}
printf("%d\n",a[m]-a[n-1]);
}
return 0;
}