-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchu_so_nguyen_to.cpp
More file actions
72 lines (65 loc) · 1.2 KB
/
Copy pathchu_so_nguyen_to.cpp
File metadata and controls
72 lines (65 loc) · 1.2 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <bits/stdc++.h>
using namespace std;
bool la_so_chan(int n)
{
return n % 2 == 0;
}
bool la_so_nguyen_to(int n)
{
return n == 2 || n == 3 || n == 5 || n == 7;
}
bool co_day_du(int n)
{
int dem_2 = 0;
int dem_3 = 0;
int dem_5 = 0;
int dem_7 = 0;
while (n > 0)
{
int chu_so = n % 10;
if (chu_so == 2)
dem_2++;
if (chu_so == 3)
dem_3++;
if (chu_so == 5)
dem_5++;
if (chu_so == 7)
dem_7++;
n /= 10;
}
return dem_2 > 0 && dem_3 > 0 && dem_5 > 0 && dem_7 > 0;
}
bool thoa_man(int n)
{
if (la_so_chan(n))
return false;
if (!co_day_du(n))
return false;
while (n > 0)
{
int chu_so = n % 10;
if (!la_so_nguyen_to(chu_so))
return false;
n /= 10;
}
return true;
}
void in_ra(int n)
{
int duoi = pow(10, n - 1);
int tren = pow(10, n) - 1;
for (int i = duoi; i <= tren; i++)
{
if (thoa_man(i))
{
cout << i << endl;
}
}
}
int main()
{
int n;
cin >> n;
in_ra(n);
return 0;
}