http://acm.hdu.edu.cn/showproblem.php?pid=2089
#include <stdio.h>
const int M=101000;
int dp[M];// 前i个数字中 unlucky num个数
int fun(int x)
{
int a[M],i,j,k;
i=0;
while(x)
{
if(x%10==4)
return 1;
if(x%10==6&&a[i]==2)
return 1;
a[++i]=x%10;
x=x/10;
}
return 0;
}
int main()
{
int n,m,i,j,k;
dp[0]=0;
for(i=1;i<=M;i++)
{
dp[i]=dp[i-1]+fun(i);// dp[i]=dp[i-1]+(0,1)看a[i]是否为 unlucky num
}
while(scanf("%d%d",&n,&m)&&(n+m))
{
printf("%d\n",(m-n+1)-(dp[m]-dp[n-1]));
}
return 0;
}