Skip to content
C

N Queens

Hardjavapythonccppjavascript

Count the number of distinct ways to place N queens on an N x N chessboard so that no two queens attack each other (no two share a row, column or diagonal).

Input Format

A single line containing the integer N.

Output Format

Print the number of valid arrangements.

Input (stdin)

Output

Run your code to see output here...