dfs练习题
文章平均质量分 86
geekword
无无无
展开
-
N皇后问题
Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。Input 共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output 共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sampl原创 2016-07-24 08:47:20 · 207 阅读 · 0 评论 -
Prime Ring Problem
Description 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 nu原创 2016-07-24 08:58:18 · 167 阅读 · 0 评论 -
Network Saboteur
Description A university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided the network into two subnetworks in order to原创 2016-07-24 09:06:48 · 247 阅读 · 0 评论 -
速算24点
Description 速算24点相信绝大多数人都玩过。就是随机给你四张牌,包括A(1),2,3,4,5,6,7,8,9,10,J(11),Q(12),K(13)。要求只用’+’,’-‘,’*’,’/’运算符以及括号改变运算顺序,使得最终运算结果为24(每个数必须且仅能用一次)。游戏很简单,但遇到无解的情况往往让人很郁闷。你的任务就是针对每一组随机产生的四张牌,判断是否有解。我们另外规定,整个计算转载 2016-07-24 10:17:07 · 4417 阅读 · 0 评论 -
Sticks
Description 速算24点相信绝大多数人都玩过。就是随机给你四张牌,包括A(1),2,3,4,5,6,7,8,9,10,J(11),Q(12),K(13)。要求只用’+’,’-‘,’*’,’/’运算符以及括号改变运算顺序,使得最终运算结果为24(每个数必须且仅能用一次)。游戏很简单,但遇到无解的情况往往让人很郁闷。你的任务就是针对每一组随机产生的四张牌,判断是否有解。我们另外规定,整个计算转载 2016-07-24 10:21:51 · 664 阅读 · 0 评论 -
POJ - 2386 dfs-Lake Counting
Description Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains ei原创 2016-08-04 21:04:29 · 274 阅读 · 0 评论 -
POJ 1915 BFS-Knight Moves
Description Background Mr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him? The Problem Your task is原创 2016-08-02 16:17:28 · 211 阅读 · 0 评论