HDU 2089 不要62 --- 水题+打表

HDU 2089 不要62

/* HDU 2089 不要62 --- 水题+打表 */
#include <cstdio>
#include <cstring>

const int maxn = 1000005;
bool a[maxn];

int main()
{
    memset(a, 0, sizeof a);
    int j;
    for (int i = 1; i < maxn; ++i){
        j = i;
        while (j){
            if (j % 10 == 4 || j % 100 == 62){
                a[i] = 1;
                break;
            }
            j /= 10;
        }
    }
    int n, m, sum;
    while (scanf("%d%d", &n, &m) == 2 && (n+m)){
        sum = 0;
        for (int i = n; i <= m; ++i){
            sum += a[i];
        }
        printf("%d
", m-n+1-sum);
    }

    return 0;
}
View Code
原文地址:https://www.cnblogs.com/tommychok/p/5065446.html