摘要: 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 阅读(342) 评论(0) 推荐(0) 编辑
摘要: Description勇敢的德鲁伊法里奥出色的完成了任务之后,正在迅速的向自己的基地撤退。但由于后面有着一大群追兵,所以法里奥要尽快地返回基地,否则就会被敌人捉住。终于,法里奥来到了最后的一站:泰拉希尔原野,穿过这里就可以回到基地了。然而,敌人依然紧追不舍。不过,泰拉希尔的地理条件对法里奥十分有利,众多的湖泊随处分布。敌人需要绕道而行,但法里奥拥有变成鹰的特殊能力,使得他能轻轻松松的飞越湖面。当然,为了保证安全起见,法里奥还是决定找一条能最快回到基地的路。假设泰拉希尔原野是一个m*n的矩阵,它有两种地形,P表示平地,L表示湖泊,法里奥只能停留在平地上。他目前的位置在左上角(1,1)处,而目的地 阅读全文
posted @ 2013-01-25 15:56 Cielsk 阅读(786) 评论(0) 推荐(0) 编辑
摘要: Description在众多的数据结构中,二叉树是一种特殊而重要的结构,有着广泛的应用。二叉树或者是一个结点,或者有且仅有一个结点为二叉树的根,其余结点被分成两个互不相交的子集,一个作为左子集,另一个作为右子集,每个子集又是一个二叉树。遍历一棵二叉树就是按某条搜索路径巡访其中每个结点,使得每个结点均被访问一次,而且仅被访问一次。最常使用的有三种遍历的方式:1.前序遍历:若二叉树为空,则空操作;否则先访问根结点,接着前序遍历左子树,最后再前序遍历右子树。2.中序遍历:若二叉树为空,则空操作;否则先中序遍历左子树,接着访问根结点,最后再前中遍历右子树。3.后序遍历:若二叉树为空,则空操作;否则先后 阅读全文
posted @ 2013-01-25 15:54 Cielsk 阅读(361) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of security to change such things every now and then, to keep the enemy in the dark.— But look, 阅读全文
posted @ 2013-01-25 15:53 Cielsk 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Description在一个神秘的国度里,年轻的王子Paris与美丽的公主Helen在一起过着幸福的生活。他们都随身带有一块带磁性的阴阳魔法石,身居地狱的魔王Satan早就想得到这两块石头了,只要把它们熔化,Satan就能吸收其精华大增自己的魔力。于是有一天他趁二人不留意,把他们带到了自己的地牢,分别困在了不同的地方。然后Satan念起了咒语,准备炼狱,界时二人都将葬身于这地牢里。危险!Paris与Helen都知道了Satan的意图,他们要怎样才能打败魔王,脱离地牢呢?Paris想起了父王临终前留给他的备忘本,原来他早已料到了Satan的野心,他告诉Paris只要把两块魔法石合在一起,念出咒语 阅读全文
posted @ 2013-01-25 15:52 Cielsk 阅读(229) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe game of ‘Inverso’ is played on a 3x3 grid of colored fields (each field is either black or white). Each field is numbered as follows:1 2 34 5 67 8 9The player can click on a field, which will result in the inversion of that field and all its direct neighboring fields (i.e. the color c 阅读全文
posted @ 2013-01-25 15:49 Cielsk 阅读(304) 评论(0) 推荐(0) 编辑
摘要: DescriptionIn the field of computer science, forest is important and deeply researched , it is a model for many data structures . Now it’s your job here to calculate the depth and width of given forests.Precisely, a forest here is a directed graph with neither loop nor two edges pointing to the same 阅读全文
posted @ 2013-01-25 15:48 Cielsk 阅读(323) 评论(0) 推荐(0) 编辑
摘要: DescriptionLenny likes to play the game of lotto. In the lotto game, he picks a list ofNunique numbers in the range from1toM. If his list matches the list of numbers that are drawn, he wins the big prize.Lenny has a scheme that he thinks is likely to be lucky. He likes to choose his list so that eac 阅读全文
posted @ 2013-01-25 15:47 Cielsk 阅读(188) 评论(0) 推荐(0) 编辑
摘要: DescriptionIrv Kenneth Diggit works for a company that excavates trenches, digs holes and generally tears up people's yards. Irv's job is to make sure that no underground pipe or cable is underneath where excavation is planned. He has several different maps, one for each utility company, sho 阅读全文
posted @ 2013-01-25 15:46 Cielsk 阅读(394) 评论(0) 推荐(0) 编辑
摘要: DescriptionGiven a sequence of consecutive integers n,n+1,n+2,...,m, an anti-prime sequence is a rearrangement of these integers so that each adjacent pair of integers sums to a composite (non-prime) number. For example, if n = 1 and m = 10, one such anti-prime sequence is 1,3,5,4,2,6,9,7,8,10. This 阅读全文
posted @ 2013-01-25 15:45 Cielsk 阅读(197) 评论(0) 推荐(0) 编辑
摘要: DescriptionAt present, Zhongshan University has 4 campuses with a total area of 6.17 square kilometers sitting respectively on both sides of the Pearl River or facing the South China Sea. The Guangzhou South Campus covers an area of 1.17 square kilometers, the North Campus covers an area of 0.39 squ 阅读全文
posted @ 2013-01-25 15:43 Cielsk 阅读(329) 评论(0) 推荐(0) 编辑
摘要: DescriptionThere are N cities and N-1 roads in Magic-Island. You can go from one city to any other. One road only connects two cities. One day, The king of magic-island want to visit the island from the capital. No road is visited twice. Do you know the longest distance the king can go.InputThere ar 阅读全文
posted @ 2013-01-25 15:42 Cielsk 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 这三道题目大体相同,只是数据处理方式不同,需要修改的地方很少,因此只以1150为例说明即可。Description魔板由8个大小相同方块组成,分别用涂上不同颜色,用1到8的数字表示。其初始状态是1 2 3 48 7 6 5对魔板可进行三种基本操作:A操作(上下行互换):8 7 6 51 2 3 4B操作(每次以行循环右移一个):4 1 2 35 8 7 6C操作(中间四小块顺时针转一格):1 7 2 48 6 3 5用上述三种基本操作,可将任一种状态装换成另一种状态。Input输入包括多个要求解的魔板,每个魔板用三行描述。第一行步数N(不超过10的整数),表示最多容许的步数。第二、第三行表示目 阅读全文
posted @ 2013-01-25 15:41 Cielsk 阅读(460) 评论(0) 推荐(0) 编辑