LogiQuest

215. N-Queens Solutions Count

HardBacktracking

Count the ways to place n queens on an n×n board 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 ≤ 10

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…