N-queens problem - MarisaOJ: Marisa Online Judge

N-queens problem

Time limit: 1000 ms
Memory limit: 256 MB
Count the number of ways to place $n$ queens on a board of size $n \times n$ so that no two queens are attacking each other. An example way of placing $5$ queens: ``` X.... ...X. .X... ....X ..X.. ``` ### Input - A single integer $n$. ### Output - The number of ways to place $n$ queens. ### Constraints - $1 \le n \le 10$. ### Example Input: ``` 5 ``` Output: ``` 10 ```