/* Question: the same as a poj Board question, however, it is necessary to determine the case that it cannot be a diagonal line */# include <iostream> # include <cstring> # include <cmath> using namespace STD; int res [12]; // Save the expected output result int Visi [12]; // int ma [12] When each column is accessed; // It is used to store the location of the Queen, avoid int sum, L; void DFS (INT row, int POS) {If (Pos = L) {sum ++; return;} on the same diagonal ;} if (row> L) return; For (Int J = 1; j <= L; j ++) if (! Visi [J]) {int flag = 0; MA [row] = J; For (int K = 1; k <row; k ++) if (ABS (MA [k]-ma [row]) = ABS (Row-k) {flag = 1; break;} If (! Flag) {Visi [J] = 1; DFS (row + 1, POS + 1); Visi [J] = 0 ;}} DFS (row + 1, POS ); return;} int main () {for (L = 1; L <= 10; l ++) {memset (Visi, 0, sizeof (Visi); sum = 0; DFS (); Res [l] = sum;} int P; while (CIN> P & P) {cout <res [p] <Endl ;} return 0 ;}