随笔分类 -  DFS

摘要:Description汉诺塔(又称河内塔)问题是源于印度一个古老传说的益智玩具。大梵天创造世界的时候做了三根金刚石柱子,在一根柱子上从下往上按照大小顺序摞着64片黄金圆盘。大梵天命令婆罗门把圆盘从下面开始按大小顺序重新摆放在另一根柱子上。并且规定,在小圆盘上不能放大圆盘,在三根柱子之间一次只能移动一... 阅读全文
posted @ 2015-04-20 19:51 Painting、时光 阅读(1424) 评论(0) 推荐(0)
摘要:Description一个猴子在一座不超过30级的小山上爬山跳跃,猴子上山一步可跳1级或跳3级,试求上山有多少种不同的爬法Input多组测试数据,每组输入1个整数n,表示山的台阶数Output对于输入的整数n求出多少种爬法Sample Input30Sample Output58425HINT大意:... 阅读全文
posted @ 2015-04-20 18:05 Painting、时光 阅读(2057) 评论(0) 推荐(0)
摘要:Description给你一副无向图,每条边有边权,保证图联通,现在让你判断这个图是否有异或值大于零的环存在。Input多组测试数据,每组先输入两个数n m,表示图的点跟边的数量。然后是m行,每行三个数a b c。代表一条边的起点,终点,边权。1 #include#includeusing name... 阅读全文
posted @ 2015-04-18 18:48 Painting、时光 阅读(801) 评论(0) 推荐(0)
摘要:Pattern lock security is generally used in Android handsets instead of a password. The pattern lock can be set by joining points on a 3 × 3 matrix in ... 阅读全文
posted @ 2015-04-13 12:53 Painting、时光 阅读(227) 评论(0) 推荐(0)
摘要:DescriptionSome positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given pos... 阅读全文
posted @ 2015-03-27 18:55 Painting、时光 阅读(163) 评论(0) 推荐(0)
摘要:Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空... 阅读全文
posted @ 2015-03-24 18:58 Painting、时光 阅读(193) 评论(0) 推荐(0)
摘要:DescriptionBMan和hyx住在一个神奇的国度,这个国度有N个城市,这N个城市间只有N-1条路把这个N个城市连接起来。 现在BMan在第S号城市,他经常想起那个一起AC过的队友hyx,记忆它总是慢慢的累积,在他心中无法抹去,可是他并不知道hyx 在哪个城市,所以他决定用尽半年的积蓄漂洋过海... 阅读全文
posted @ 2015-03-17 15:56 Painting、时光 阅读(223) 评论(0) 推荐(0)
摘要:DescriptionBackgroundThe knight is getting bored of seeing the same black and white squares again and again and has decided to make a journeyaround th... 阅读全文
posted @ 2015-03-13 21:13 Painting、时光 阅读(162) 评论(0) 推荐(0)
摘要:借用朋友的代码,感觉很正规,链接http://home.cnblogs.com/u/get-an-AC-everyday/DescriptionThe game “The Pilots Brothers: following the stripy elephant” has a quest wher... 阅读全文
posted @ 2015-03-04 13:44 Painting、时光 阅读(124) 评论(0) 推荐(0)
摘要:DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and ... 阅读全文
posted @ 2015-03-04 13:36 Painting、时光 阅读(153) 评论(0) 推荐(0)