1832: 【提高】八皇后问题

Memory Limit:16 MB Time Limit:1.000 S
Creator:
Submit:3 Solved:0

Description

在国际象棋棋盘上放置八个皇后,要求每两个皇后之间不能直接吃掉对方。

Input

无输入。

Output

按给定顺序和格式输出所有八皇后问题的解(见Sample Output)。

Sample Output

No. 1

1 0 0 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 0 0 1 0 0 0 

0 0 0 0 0 0 0 1 

0 1 0 0 0 0 0 0 

0 0 0 1 0 0 0 0 

0 0 0 0 0 1 0 0 

0 0 1 0 0 0 0 0 

No. 2

1 0 0 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 0 1 0 0 0 0 

0 0 0 0 0 1 0 0 

0 0 0 0 0 0 0 1 

0 1 0 0 0 0 0 0 

0 0 0 0 1 0 0 0 

0 0 1 0 0 0 0 0 

No. 3

1 0 0 0 0 0 0 0 

0 0 0 0 0 1 0 0 

0 0 0 0 0 0 0 1 

0 0 1 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 0 1 0 0 0 0 

0 1 0 0 0 0 0 0 

0 0 0 0 1 0 0 0 

No. 4

1 0 0 0 0 0 0 0 

0 0 0 0 1 0 0 0 

0 0 0 0 0 0 0 1 

0 0 0 0 0 1 0 0 

0 0 1 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 1 0 0 0 0 0 0 

0 0 0 1 0 0 0 0 

No. 5

0 0 0 0 0 1 0 0 

1 0 0 0 0 0 0 0 

0 0 0 0 1 0 0 0 

0 1 0 0 0 0 0 0 

0 0 0 0 0 0 0 1 

0 0 1 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 0 1 0 0 0 0 

No. 6

0 0 0 1 0 0 0 0 

1 0 0 0 0 0 0 0 

0 0 0 0 1 0 0 0 

0 0 0 0 0 0 0 1 

0 1 0 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 1 0 0 0 0 0 

0 0 0 0 0 1 0 0 

No. 7

0 0 0 0 1 0 0 0 

1 0 0 0 0 0 0 0 

0 0 0 0 0 0 0 1 

0 0 0 1 0 0 0 0 

0 1 0 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 1 0 0 0 0 0 

0 0 0 0 0 1 0 0 

No. 8

0 0 1 0 0 0 0 0 

1 0 0 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 0 0 1 0 0 0 

0 0 0 0 0 0 0 1 

0 1 0 0 0 0 0 0 

0 0 0 1 0 0 0 0 

0 0 0 0 0 1 0 0 

No. 9

0 0 0 0 1 0 0 0 

1 0 0 0 0 0 0 0 

0 0 0 1 0 0 0 0 

0 0 0 0 0 1 0 0 

0 0 0 0 0 0 0 1 

0 1 0 0 0 0 0 0 

0 0 0 0 0 0 1 0 

0 0 1 0 0 0 0 0 

...以下省略

HINT


此题可使用函数递归调用的方法求解。

Source/Category