On an n x n chessboard, place n queens so that no two attack each
other (no two queens share a row, column, or diagonal). Read the positive
natural number n. Determine and print the total number of valid
arrangements.
On an n x n chessboard, place n queens so that no two attack each
other (no two queens share a row, column, or diagonal). Read the positive
natural number n. Determine and print the total number of valid
arrangements.
The program reads from standard input a single natural number, `n`. - `1 <= n <= 8` - For `n = 2` and `n = 3` the answer is `0`.
The program prints a single natural number followed by a newline: the number of valid arrangements.
4
2
Use the Get Hint button in the action bar to reveal a guided hint.
No comments yet. Be the first to start the discussion!
4
2
Community solutions unlock after you submit a passing solution. Don't peek.
Create a free account to write code, submit solutions, and track your progress.