-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1618.cpp
81 lines (81 loc) · 2.78 KB
/
P1618.cpp
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
73
74
75
76
77
78
79
80
81
#include <iostream>
using namespace std;
bool visit[10];
int main()
{
bool flag = false;
int A, B, C;
cin >> A >> B >> C;
int a, b, c;
int d, e, f;
int g, h, i;
for (a = 1; a <= 9; a++)
{
visit[a] = true;
for (b = 1; b <= 9; b++)
{
if (visit[b])
continue;
visit[b] = true;
for (c = 1; c <= 9; c++)
{
if (visit[c])
continue;
visit[c] = true;
for (d = 1; d <= 9; d++)
{
if (visit[d])
continue;
visit[d] = true;
for (e = 1; e <= 9; e++)
{
if (visit[e])
continue;
visit[e] = true;
for (f = 1; f <= 9; f++)
{
if (visit[f])
continue;
visit[f] = true;
for (g = 1; g <= 9; g++)
{
if (visit[g])
continue;
visit[g] = true;
for (h = 1; h <= 9; h++)
{
if (visit[h])
continue;
visit[h] = true;
for (i = 1; i <= 9; i++)
{
if (visit[i])
continue;
visit[i] = true;
if ((a * 100 + b * 10 + c) * B == (d * 100 + e * 10 + f) * A && (a * 100 + b * 10 + c) * C == (g * 100 + h * 10 + i) * A)
{
flag = true;
cout << a << b << c << " " << d << e << f << " " << g << h << i << "\n";
}
visit[i] = false;
}
visit[h] = false;
}
visit[g] = false;
}
visit[f] = false;
}
visit[e] = false;
}
visit[d] = false;
}
visit[c] = false;
}
visit[b] = false;
}
visit[a] = false;
}
if (!flag)
cout << "No!!!";
return 0;
}