摘要: DescriptionIn the two-player game "Two Ends", an even number of cards is laid out in a row. On each card, face up, is written a positive integer. Players take turns removing a card from either end of the row and placing the card in their pile. The player whose cards add up to the highest n 阅读全文
posted @ 2013-01-30 20:49 Cielsk 阅读(167) 评论(0) 推荐(0) 编辑
摘要: DescriptionDuring the rainy season, one of the walls in the house is infested with mosquitoes. The wall is covered by h × w square tiles, where there are h rows of tiles from top to bottom, and w columns of tiles from left to right. Each tile has 1 to 1000 mosquitoes resting on it.A gecko wants 阅读全文
posted @ 2013-01-25 16:06 Cielsk 阅读(194) 评论(0) 推荐(0) 编辑
摘要: DescriptionYou are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may connect pairs of points. For each possible route between two points, you are given the length of the cable 阅读全文
posted @ 2013-01-25 16:05 Cielsk 阅读(304) 评论(0) 推荐(0) 编辑
摘要: DescriptionBruce是K国的商人,他在A州成立了自己的公司,这次他的公司生产出了一批性能很好的产品,准备宣传活动开始后的第L天到达B州进行新品拍卖,期间Bruce打算将产品拿到各个州去做推销宣传,以增加其影响力。K国有很多个州,每个州都与其他一些州相邻,但是K国对商人作宣传却有一些很奇怪的规定:1、商人只能从某些州到达另外一些州,即连通路线是单向的,而且有些州可能是到达不了的。2、商人不允许在同一个州连续宣传两天或以上,每天宣传完必须离开该州。3、商人可以多次来到同一个州进行宣传。"我必须找出一条影响力最大的路线才行",Bruce想,"但我首先必须知道 阅读全文
posted @ 2013-01-25 16:03 Cielsk 阅读(234) 评论(0) 推荐(0) 编辑
摘要: DescriptionYour task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from another. The possible knight moves are shown in Figure 1.Figure 1 Possible knight moves on the boardInputThe first line contains an integerT(≤10), indicating the number of 阅读全文
posted @ 2013-01-25 16:02 Cielsk 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Description对于二叉树T,可以递归定义它的先序遍历、中序遍历和后序遍历如下: PreOrder(T)=T的根节点+PreOrder(T的左子树)+PreOrder(T的右子树) InOrder(T)=InOrder(T的左子树)+T的根节点+InOrder(T的右子树) PostOrder(T)=PostOrder(T的左子树)+PostOrder(T的右子树)+T的根节点 其中加号表示字符串连接运算。例如,对下图所示的二叉树,先序遍历为DBACEGF,中序遍历为ABCDEFG。输入一棵二叉树的先序遍历序列和中序遍历序列,输出它的广度优先遍历序列。Input第一行为一个整数t(0&l 阅读全文
posted @ 2013-01-25 16:01 Cielsk 阅读(461) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some highways so that it will be possible to drive between any pair of 阅读全文
posted @ 2013-01-25 16:00 Cielsk 阅读(311) 评论(0) 推荐(0) 编辑
摘要: DescriptionIn the early 80’s, a popular TV show on Dutch television was ‘Cijfers en Letters’ (Numbers and Letters). This game consisted of two game elements, in which the main goal was to outclass your opponent. Letters is a game in which you are given a number of letters with which you should form 阅读全文
posted @ 2013-01-25 15:58 Cielsk 阅读(195) 评论(0) 推荐(0) 编辑
摘要: DescriptionSudoku is a placement puzzle. The goal is to enter a symbol in each cell of a grid, most frequently a9x9grid made up of3x3subgrids. Each row, column and subgrid must contain only one instance of each symbol. Sudoku initially became popular in Japan in 1986 and attained international popul 阅读全文
posted @ 2013-01-25 15:57 Cielsk 阅读(341) 评论(0) 推荐(0) 编辑
摘要: Description勇敢的德鲁伊法里奥出色的完成了任务之后,正在迅速的向自己的基地撤退。但由于后面有着一大群追兵,所以法里奥要尽快地返回基地,否则就会被敌人捉住。终于,法里奥来到了最后的一站:泰拉希尔原野,穿过这里就可以回到基地了。然而,敌人依然紧追不舍。不过,泰拉希尔的地理条件对法里奥十分有利,众多的湖泊随处分布。敌人需要绕道而行,但法里奥拥有变成鹰的特殊能力,使得他能轻轻松松的飞越湖面。当然,为了保证安全起见,法里奥还是决定找一条能最快回到基地的路。假设泰拉希尔原野是一个m*n的矩阵,它有两种地形,P表示平地,L表示湖泊,法里奥只能停留在平地上。他目前的位置在左上角(1,1)处,而目的地 阅读全文
posted @ 2013-01-25 15:56 Cielsk 阅读(734) 评论(0) 推荐(0) 编辑