编写一个函数 n_queens,接受一个正整数 N 作为参数,返回一个 N 皇后问题的解决方案个数,即在 N×N 的棋盘上放置 N 个皇后,使得它们互相不能攻击(即不在同一行、同一列或同一对角线上)。
n_queens
N
N×N
输入方式:
input()
输出方式:
print()
输入输出示例
# 输入: 3 # 输出: 0
# 输入: 5 # 输出: 10
By signing up a Hydro universal account, you can submit code and join discussions in all online judging services provided by us.
Using your Hydro universal account