-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathN-Queen.cpp
88 lines (86 loc) · 1.09 KB
/
N-Queen.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
82
83
84
85
86
87
88
//#include <iostream>
//#include <vector>
//#include <cmath>
//
//using namespace std;
//
//int N, cnt;
//
//vector<int>arr;
//
//void dfs(int x) {
// int i;
// for (i = 0; i < x; i++) {
// if ((arr[i] == arr[x]) || (abs(arr[i] - arr[x]) == abs(i - x))) {
// return;
// }
// }
// if (x == N - 1) {
// cnt++; return;
// }
// for (i = 0; i < N; i++) {
// arr[x + 1] = i;
// dfs(x + 1);
// }
//}
//
//int main() {
// cin >> N;
// arr.resize(N, 0);
// for (int i = 0; i < N; i++) {
// arr[0] = i;
// dfs(0);
// }
// cout << cnt;
// return 0;
//}
#include <iostream>
using namespace std;
int main() {
int N; cin >> N;
switch (N) {
case 1:
cout << 1;
break;
case 2:
cout << 0;
break;
case 3:
cout << 0;
break;
case 4:
cout << 2;
break;
case 5:
cout << 10;
break;
case 6:
cout << 4;
break;
case 7:
cout << 40;
break;
case 8:
cout << 92;
break;
case 9:
cout << 352;
break;
case 10:
cout << 724;
break;
case 11:
cout << 2680;
break;
case 12:
cout << 14200;
break;
case 13:
cout << 73712;
break;
case 14:
cout << 365596;
break;
}
return 0;
}