11. N-Queens Count
HardBacktracking
Count the ways to place n queens on an n × n chessboard so that no two attack each other.
Input format
A single integer n.
Output format
The number of solutions.
Example 1
Input
4
Output
2
Example 2
Input
1
Output
1
Constraints
1 ≤ n ≤ 9
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…