#P0027. N皇后问题

N皇后问题

1. Description

Code a function n_queens, which takes an integer N as input and returns the number of ways that all N Queens can survive on an NxN board and don't attack each other (For any two queens, they don't place on same row, column or diagonal)

2. Input & Output

Input:

  • An integer N
  • Use input() as input. Notice that the value you get from input() is a string

Output:

  • An integer representing number of solutions
  • Use print() for your output

Example

# Input: 
3
# Output: 
0
# Input: 
5
# Output: 
10