HDOJ 2089 不要62

打表,不然会超时~~~

HOHO

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 // Accepted 2089 140MS 4092K 686B C++ Tanky Woo 
// Author: Tanky Woo
// HDOJ 2089
#include <iostream>
using namespace std;
// www.wutianqi.com
int m, n;
int dabiao[1000001];
bool Is_no_good(int i)
{
	int temp = i;
	while(temp)
	{
		if(temp % 10 == 4)
			return 1;
		temp /= 10;
	}
	temp = i;
	while(temp)
	{
		if(temp % 100 == 62)
			return 1;
		temp /= 10;
	}
	return 0;
}
 
int main()
{
	//freopen("dabiao.txt", "w", stdout);
	dabiao[0] = 0;
	for(int i = 1; i < 1000001; ++i)
		if(Is_no_good(i))
			dabiao[i] = 0;
		else
			dabiao[i] = 1;
	while(scanf("%d %d", &m, &n) && (m||n))
	{
		int cnt = 0;
		for(int i = m; i <= n; ++i)
			if(dabiao[i])
				cnt++;
		printf("%d\n", cnt);
	}
	re

发布者

Tanky Woo

Tanky Woo,[个人主页:https://tankywoo.com] / [新博客:https://blog.tankywoo.com]

发表评论

电子邮件地址不会被公开。 必填项已用*标注