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

/**
* With N-Queens solution, we could know how many valid boards for certain number of Queen,
* since the result never change, we could just cache them, and return the cached number.
*/
int totalNQueens(int n){ static int results[19] = { 0, 1, 0, 0, 2, 10, 4, 40, 92, 352, 724, 2680, 14200, 73712, 365596, 2279184, 14772512, 95815104, 666090624, }; return results[n]; }
View Program Text


Test Status