HDU 2089 不要62

http://acm.hdu.edu.cn/showproblem.php?pid=2089

#include <iostream> 
#include <cstdio> 
#include <cstring>

#define N 1000010
int flag[N];

using namespace std;

int main()
{
    int n;
    int m;
    int i;
    int temp;
    int amount;
    
    memset(flag,0,sizeof(flag));

    for(i=1;i<=N;i++)
    {
        temp=i;
        while(temp)
        {
            if(temp%10==4 || temp%100==62)
            {
                flag[i]=1;
                break;
            }
            temp/=10;
        }
    }
    
    while(1)
    {
        scanf("%d%d",&n,&m);
        
        if(n==0 && m==0)    
            break;
        
        amount=0;    
        for(i=n;i<=m;i++)
        {
            if(flag[i]==1)
                amount++;
        }
        
        printf("%d\n",m-n+1-amount);
    }

    return 0;
}
posted @ 2018-08-29 12:59  ronnie14165  阅读(73)  评论(0编辑  收藏  举报