Description:

杭州人称傻乎乎的人为62,而嘟嘟家这里没有这样的习俗。相比62,他那里的人更加讨厌数字38,当然啦,还有4这个数字!所以啊,嘟嘟不点都不想见到包含38或者4的数字。每次给出一个区间[n,m],你能找到所有令人讨厌的数字吗?

Input:

多组输入输出;

输入的都是整数对n、m( 0 &lt; n m &lt; 1000000 0&lt;n\le m&lt;1000000 0<nm<1000000),

如果遇到都是0的整数对,则输入结束。

Output:

对于每次的输入

输出全部令人讨厌的数的个数

Sample Input:

1 100
0 0

Sample Output:

20

题目链接

思路:对范围内所有数提取每两位和每一位数判断是否和38或者4相等,打表

AC代码:

#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
#define lowbit(x) (x&(-x))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int INF = 0x3f3f3f3f;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = asin(1.0) * 2;
const double e = 2.718281828459;
bool Finish_read;
template<class T>inline void read(T &x) {
	Finish_read = 1;
	x = 0;
	int f = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') {
			f = -1;
		}
		if (ch == EOF) {
			return;
		}
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	x *= f;
	Finish_read = 1;
};

bool IsLike[maxn];
int UnlikeNum[maxn];

bool judge(int x) {
	while (x) {
		if (x % 10 == 4 || x % 100 == 38) {
			return 1;
		}
		x /= 10;
	}
	return 0;
}

void init() {
	mem(IsLike, 0);
	mem(UnlikeNum, 0);
	for (int i = 1; i < maxn; ++i) {
		if (judge(i)) {
			IsLike[i] = 1;
		}
		UnlikeNum[i] = UnlikeNum[i - 1] + IsLike[i];
	}
}

int main(int argc, char *argv[]) {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
	init();
	int n, m;
	while (~scanf("%d %d", &n, &m) && (n + m)) {
		printf("%d\n", UnlikeNum[m] - UnlikeNum[n - 1]);
	}
#ifndef ONLINE_JUDGE
    fclose(stdin);
    fclose(stdout);
    system("gedit out.txt");
#endif
    return 0;
}