N-Queen
InterviewTime limit10sMemory limit128 MB
Count the ways to place N non-attacking queens on an N by N board for N under 15.
- Level
Medium5 of 10
- Topics
- Backtracking, Bit manipulation
- Solved
- No attempts yet
Problem
The N-Queen problem asks for placements of queens on an chessboard in which no queen attacks another. A queen attacks every other queen in its row, in its column, and on its diagonals.
Given , write a program that counts the placements of the queens. Placements that coincide after a rotation or a reflection are counted separately.
Input
The first line contains ().
Output
Print the number of placements of queens in which no queen attacks another.