
回溯
文章平均质量分 83
czdb
这个作者很懒,什么都没留下…
展开
-
N皇后问题 HDU - 2553
在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。 Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。 Sample原创 2016-12-14 21:39:51 · 298 阅读 · 0 评论 -
Prime Ring Problem HDU - 1016
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacent circles should be a prime. Note: the number原创 2016-12-15 14:13:37 · 256 阅读 · 0 评论