03 2012 档案

摘要:DescriptionThe Pizazz Pizzeria prides itself in delivering pizzas to its customers as fast as possible. Unfortunately, due to cutbacks, they can afford to hire only one driver to do the deliveries. He will wait for 1 or more (up to 10) orders to be processed before he starts any deliveries. Needless 阅读全文
posted @ 2012-03-31 19:45 'wind 阅读(616) 评论(0) 推荐(0)
摘要:DescriptionFarmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertile and can't be planted. Canny FJ knows that the cows 阅读全文
posted @ 2012-03-30 21:51 'wind 阅读(354) 评论(0) 推荐(0)
摘要:Problem Description小t非常感谢大家帮忙解决了他的上一个问题。然而病毒侵袭持续中。在小t的不懈努力下,他发现了网路中的“万恶之源”。这是一个庞大的病毒网站,他有着好多好多的病毒,但是这个网站包含的病毒很奇怪,这些病毒的特征码很短,而且只包含“英文大写字符”。当然小t好想好想为民除害,但是小t从来不打没有准备的战争。知己知彼,百战不殆,小t首先要做的是知道这个病毒网站特征:包含多少不同的病毒,每种病毒出现了多少次。大家能再帮帮他吗?Input第一行,一个整数N(1<=N<=1000),表示病毒特征码的个数。接下来N行,每行表示一个病毒特征码,特征码字符串长度在1—5 阅读全文
posted @ 2012-03-30 19:05 'wind 阅读(237) 评论(0) 推荐(0)
摘要:Problem DescriptionHow can anagrams result from sequences of stack operations? There are two sequences of stack operators which can convert TROT to TORT: [i i i i o o o oi o i i o o i o]where i stands for Push and o stands for Pop. Your program should, given pairs of words produce sequences of stack 阅读全文
posted @ 2012-03-30 17:30 'wind 阅读(216) 评论(0) 推荐(0)
摘要:Problem Description当太阳的光辉逐渐被月亮遮蔽,世界失去了光明,大地迎来最黑暗的时刻。。。。在这样的时刻,人们却异常兴奋——我们能在有生之年看到500年一遇的世界奇观,那是多么幸福的事儿啊~~但网路上总有那么些网站,开始借着民众的好奇心,打着介绍日食的旗号,大肆传播病毒。小t不幸成为受害者之一。小t如此生气,他决定要把世界上所有带病毒的网站都找出来。当然,谁都知道这是不可能的。小t却执意要完成这不能的任务,他说:“子子孙孙无穷匮也!”(愚公后继有人了)。万事开头难,小t收集了好多病毒的特征码,又收集了一批诡异网站的源码,他想知道这些网站中哪些是有病毒的,又是带了怎样的病毒呢? 阅读全文
posted @ 2012-03-29 23:09 'wind 阅读(240) 评论(0) 推荐(0)
摘要:DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue listed these numbers:Emergency 911Alice 97 625 999Bob 91 12 54 26In this case, it's not possible to call Bob, because the central would 阅读全文
posted @ 2012-03-29 21:01 'wind 阅读(161) 评论(0) 推荐(0)
摘要:Problem Description我们大家经常用google检索信息,但是检索信息的程序是很困难编写的;现在请你编写一个简单的全文检索程序。问题的描述是这样的:给定一个信息流文件,信息完全有数字组成,数字个数不超过60000个,但也不少于60个;再给定一个关键字集合,其中关键字个数不超过10000个,每个关键字的信息数字不超过60个,但也不少于5个;两个不同的关键字的前4个数字是不相同的;由于流文件太长,已经把它分成多行;请你编写一个程序检索出有那些关键字在文件中出现过。Input第一行是两个整数M,N;M表示数字信息的行数,N表示关键字的个数;接着是M行信息数字,然后是一个空行;再接着是 阅读全文
posted @ 2012-03-29 14:07 'wind 阅读(230) 评论(0) 推荐(0)
摘要:Problem DescriptionIn the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature to his image retrieval system.Every image have a long description, when users type some keywords to find the image, the system will match the keywords 阅读全文
posted @ 2012-03-28 13:02 'wind 阅读(296) 评论(0) 推荐(1)
摘要:DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the following way. Given a rectangle whose upper-left corner is (x1, y1) and lower-right cor 阅读全文
posted @ 2012-03-27 17:20 'wind 阅读(325) 评论(0) 推荐(0)
摘要:Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色区域所示: 如果在地图中的灰色所标识的平原上部署一支炮兵部队,则图中的黑色的网格表示它能够攻击到的区域:沿横向左右各两格,沿纵向上下各两格。图上其它白色网格均攻击不到。从图上可见炮兵的攻击范围不受地形的影响。 现在,将军们规划如何部署炮兵部队,在防止误伤的 阅读全文
posted @ 2012-03-25 21:53 'wind 阅读(259) 评论(0) 推荐(0)
摘要:DescriptionThe most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y1999 and called it M11. It has only one eye on the left side of its head and just three feet all on the right side of its body and suffers from th 阅读全文
posted @ 2012-03-24 23:56 'wind 阅读(244) 评论(0) 推荐(0)
摘要:Problem DescriptionHogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向. 比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线,这时Ron(Harry最好的朋友)告诉Harry正好有一个魔法道具可以帮助他寻找这样的路线,而那个魔法道具上的咒语,正是由你纂写的.Input测试数据有多组,每组的表述如下:第一行有两个数,M和N,接下来是一个M行N列的地图,'*'表示障碍物,'. 阅读全文
posted @ 2012-03-24 17:04 'wind 阅读(261) 评论(0) 推荐(0)
摘要:Problem Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n 当为-1 -1时表示输入结束。 随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域, . 表示空白区域(数据保证不出现多余的空白行或者空白列)。Outpu 阅读全文
posted @ 2012-03-24 14:05 'wind 阅读(231) 评论(0) 推荐(0)
摘要:DescriptionA 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 minimize traffic between parts. A disgruntled computer science student Vasya, after being expelled f 阅读全文
posted @ 2012-03-23 18:58 'wind 阅读(177) 评论(0) 推荐(0)
摘要:Problem DescriptionFor a boat on a large body of water, strong currents can be dangerous, but with careful planning, they can be harnessed to help the boat reach its destination. Your job is to help in that planning.At each location, the current flows in some direction. The captain can choose to eit 阅读全文
posted @ 2012-03-23 13:09 'wind 阅读(250) 评论(0) 推荐(0)
摘要:DescriptionYou are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i) empty the pot ito the drain;POUR(i,j) pour from pot i to pot j; after this operation either the pot j is full (and th 阅读全文
posted @ 2012-03-22 19:27 'wind 阅读(219) 评论(0) 推荐(0)
摘要:Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?Input每个测试实例首先包括2个整数,N,M.(1 <= M <= N <= 200);在接下来的N行里,每行包括2个整数,a,b. 在第 i 行,a 代表要攻克第 i 个城堡必须先攻克第 a 个城堡,如果 a = 0 则代表可以直接攻克第 i 个城堡。b 阅读全文
posted @ 2012-03-22 17:44 'wind 阅读(319) 评论(0) 推荐(0)
摘要:Problem DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tree rooted at the rector V. E. Tretyakov. In order to make the party funny for eve 阅读全文
posted @ 2012-03-22 00:10 'wind 阅读(382) 评论(0) 推荐(0)
摘要:DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally and the maze is surrounded by solid 阅读全文
posted @ 2012-03-21 20:39 'wind 阅读(190) 评论(0) 推荐(0)
摘要:DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terrors on their quest to find the exit. One popular maze-walking strategy guarantees that the visitor will e 阅读全文
posted @ 2012-03-20 21:01 'wind 阅读(200) 评论(0) 推荐(0)
摘要:Description今年是国际数学联盟确定的“2000——世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰90周年。在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活动,你的一个好朋友XZ也有幸得以参加。活动中,主持人给所有参加活动的选手出了这样一道题目:设有一个长度为N的数字串,要求选手使用K个乘号将它分成K+1个部分,找出一种分法,使得这K+1个部分的乘积能够为最大。同时,为了帮助选手能够正确理解题意,主持人还举了如下的一个例子:有一个数字串:312, 当N=3,K=1时会有以下两种分法:1) 3*12=362) 31*2=62 这时,符合题目要求的结果是:31*2=62现 阅读全文
posted @ 2012-03-19 23:27 'wind 阅读(324) 评论(0) 推荐(0)
摘要:Description传说中的火之国一年一度的公务员选拔又开始了!木叶忍者村此次也要从中选拔出5人来,作为即将上任的新火影纲手的小弟~,可是报考公务员的人数实在是太~~多啦!所以纲手的贴身随从—静音小姐,决定对这写人进行分m批的选拔,每次笔试n人,第一次选出5人,之后每次从这n人与之前参加笔试但未选中的人一起再选出分数最高的5人,这样下来可以刷掉一大批人,但纲手只需要5人,这时候就轮到静音小姐的跟班小弟--卡卡西,来将这些人再进行二次筛选,卡卡西决定对这些人进行忍术测试,然后选出前5名,作为最后选出的人选,如果忍术分数相同,那么名字字典序靠前的被选中。Input首先是整数m和n,表示要进行m波 阅读全文
posted @ 2012-03-19 20:46 'wind 阅读(566) 评论(0) 推荐(0)
摘要:DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the posters and introduce the following rul 阅读全文
posted @ 2012-03-19 16:46 'wind 阅读(184) 评论(0) 推荐(0)
摘要:Description因为大蛇丸的捣乱,木叶忍者村痛失了和蔼的三代火影,所以身为三代火影徒弟之一的纲手不得不接受木叶村火影的职务~,因为刚刚上任,所以纲手大人需要对木叶村主要忍者的实力有个了解,以方便以后分配任务,所以我们需要统计一下每个忍者的实力高低,作为刚刚通过公务员选拔的你,这可是个很好的表现机会~你需要做的是将所有给定忍者部分实力高低关系,然后在需要的时候能够快速的查找到.Input给出一个整数n,然后n行每行给出两个名字,表示前一个忍者强于后一个,然后是一个整数m,表示m个查找,然后是m行,每行也是两个名字。输入到文件尾。忍者的个数在1000以内,名字不长于20,n<10000 阅读全文
posted @ 2012-03-18 19:02 'wind 阅读(15136) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<string.h>#include<stdlib.h>struct node{ int speed; int weight; int id;}q[1001];int cmp(const void*p1,const void*p2){ struct node*c=(struct node*)p1; struct node*d=(struct node*)p2; if(c->weight==d->weight) return d->speed-c->speed; re 阅读全文
posted @ 2012-03-18 10:09 'wind 阅读(344) 评论(0) 推荐(0)
摘要:DescriptionYour task in this problem is to determine the number of divisors of Cnk. Just for fun -- or do you need any special reason for such a useful computation?InputThe input consists of several instances. Each instance consists of a single line containing two integers n and k (0 ≤ k ≤ n ≤ 431), 阅读全文
posted @ 2012-03-17 19:03 'wind 阅读(224) 评论(0) 推荐(0)
摘要:DescriptionIt is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their functions, because these can be used to diagnose h 阅读全文
posted @ 2012-03-16 21:02 'wind 阅读(305) 评论(0) 推荐(0)
摘要:Problem Description有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b。若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c。Input第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。Output输出对应的c,每组测试数据占一行。Sample Input26 212 4Sample Output4code:View Code #include<stdio.h> int gcd( int x ,int y) { if(y==0) return x; retu... 阅读全文
posted @ 2012-03-16 17:18 'wind 阅读(155) 评论(0) 推荐(0)
摘要:Problem DescriptionEddy是个ACMer,他不仅喜欢做ACM题,而且对于纸牌也有一定的研究,他在无聊时研究发现,如果他有2N张牌,编号为1,2,3..n,n+1,..2n。这也是最初的牌的顺序。通过一次洗牌可以把牌的序列变为n+1,1,n+2,2,n+3,3,n+4,4..2n,n。那么可以证明,对于任意自然数N,都可以在经过M次洗牌后第一次重新得到初始的顺序。编程对于小于100000的自然数N,求出M的值。Input每行一个整数NOutput输出与之对应的MSample Input201Sample Output202洗牌问题:定理1:当第一张牌(牌1)回到初始位置时,所 阅读全文
posted @ 2012-03-16 17:16 'wind 阅读(556) 评论(0) 推荐(0)
摘要:DescriptionPythagorean Theorem is "humanity's greatest scientific discoveries of the ten" is a basic elementary geometry theorems."This theorem has a very long history, almost all ancient civilizations (Greece, China, Egypt, Babylon, India, etc.) have studied this theorem. Pythago 阅读全文
posted @ 2012-03-16 17:13 'wind 阅读(454) 评论(0) 推荐(0)
摘要:Problem Description反素数就是满足对于任意i(0<i<x),都有g(i)<g(x),(g(x)是x的因子个数),则x为一个反素数。现在给你一个整数区间[a,b],请你求出该区间的x使g(x)最大。Input第一行输入n,接下来n行测试数据输入包括a,b, 1<=a<=b<=5000,表示闭区间[a,b].Output输出为一个整数,为该区间因子最多的数.如果满足条件有多个,则输出其中最小的数.Sample Input32 31 1047 359Sample Output26240分析:打表。code:View Code #include&l 阅读全文
posted @ 2012-03-16 17:12 'wind 阅读(484) 评论(0) 推荐(0)
摘要:Problem Description一日,话说0068与***泛舟湖上。忽见岸边出现他的一大敌人elnil。0068当然不想落入elnil的魔爪,于是他就得想办法逃脱。这个湖是一个很规则的圆形,半径为R。此时0068正好在圆心位置。小船在湖中的速度为 V1,0068和elnil在岸上的速度都为V2。也就是说,如果0068在刚上岸的时候没被抓到,则他可逃脱。在任意时刻,0068和elnil都可以朝任何方向移动,但是0068不能一直呆上船上(会饿死的),elnil不能下水(他不会游泳)。假设0068和elnil都非常聪明,总能做对自己最有利的事情,而且两个人的体力都是无限的。请问,0068最终能 阅读全文
posted @ 2012-03-16 17:11 'wind 阅读(160) 评论(0) 推荐(0)
摘要:Description给出N个数(保证N为偶数),其中有且只有两个不同的数字出现了奇数次。请你找出他们来。Input对于每组测试数据:第一行,给出数字N,表示下一行输入N个数字,其中N为偶数(2<=N<=100000)第二行,有N个数字(每个数字保证可以使用INT表示)处理到文件结束Output对于每组测试数据:第一行,输出找到的两个数字,由小到大。Sample Input41 2 3 3Sample Output1 2分析: 第一次读入得到a^b; 第二次读入时根据a^b为1的位来把数据分为该位为1和0的两组,然后再分别异或得到a,b;code:View Code #includ 阅读全文
posted @ 2012-03-16 17:10 'wind 阅读(159) 评论(0) 推荐(0)
摘要:Problem DescriptionDilworth is the world’s most prominent collector of Russian nested dolls: he literally has thousands of them! You know, the wooden hollow dolls of different sizes of which the smallest doll is contained in the second smallest, and this doll is in turn contained in the next one and 阅读全文
posted @ 2012-03-16 17:08 'wind 阅读(202) 评论(0) 推荐(0)
摘要:DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island in the sea can be covered by a radius i 阅读全文
posted @ 2012-03-16 17:07 'wind 阅读(160) 评论(0) 推荐(0)
摘要:Problem Description“今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%...”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完整节目)Input输入数据包含多个测试实例,每个测试实例的第一行只有一个整数n(n<=100 阅读全文
posted @ 2012-03-16 17:06 'wind 阅读(426) 评论(0) 推荐(0)
摘要:Problem DescriptionHere is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play horse racing with the king and others.""Both of Tian and the king have three horses in different classes, namely, regula 阅读全文
posted @ 2012-03-16 17:05 'wind 阅读(247) 评论(0) 推荐(0)
摘要:Description前段时间,某省发生干旱,B山区的居民缺乏生活用水,现在需要从A城市修一条通往B山区的路。假设有A城市通往B山区的路由m条连续的路段组成,现在将这m条路段承包给n个工程队(n≤m≤ 300)。为了修路的便利,每个工程队只能分配到连续的若干条路段(当然也可能只分配到一条路段或未分配到路段)。假设每个工程队修路的效率一样,即每修长度为1的路段所需的时间为1。现在给出路段的数量m,工程队的数量n,以及m条路段的长度(这m条路段的长度是按照从A城市往B山区的方向依次给出,每条路段的长度均小于1000),需要你计算出修完整条路所需的最短的时间(即耗时最长的工程队所用的时间)。Inpu 阅读全文
posted @ 2012-03-16 17:04 'wind 阅读(214) 评论(0) 推荐(0)
摘要:Description现在有x个同样的球,和y个同样的杯子,现在要把这x个球全部放到y个杯子里,请问有多少种不同放法?杯子顺序没有区分,所以1,1,2和2,1,1算作一种放法Input每组输入两个整数x,y(0 <x,y< 20)处理到文件结束Output每组测试数据用一行输出所有的种类数Sample Input7 3Sample Output8code:View Code #include<stdio.h>int d(int m,int n){ if(m==0||n==1) return 1; if(m<n) return d(m,m); else return 阅读全文
posted @ 2012-03-16 17:03 'wind 阅读(184) 评论(0) 推荐(0)
摘要:Problem DescriptionEddy是个ACMer,他不仅喜欢做ACM题,而且对于Ranklist中每个人的ac数量也有一定的研究,他在无聊时经常在纸上把Ranklist上每个人的ac题目的数量摘录下来,然后从中选择一部分人(或者全部)按照ac的数量分成两组进行比较,他想使第一组中的最小ac数大于第二组中的最大ac数,但是这样的情况会有很多,聪明的你知道这样的情况有多少种吗?特别说明:为了问题的简化,我们这里假设摘录下的人数为n人,而且每个人ac的数量不会相等,最后结果在64位整数范围内.Input输入包含多组数据,每组包含一个整数n,表示从Ranklist上摘录的总人数。Outpu 阅读全文
posted @ 2012-03-16 17:02 'wind 阅读(370) 评论(0) 推荐(0)
摘要:Problem DescriptionAunt Lizzie takes half a pill of a certain medicine every day. She starts with a bottle that contains N pills.On the first day, she removes a random pill, breaks it in two halves, takes one half and puts the other half back into the bottle.On subsequent days, she removes a random 阅读全文
posted @ 2012-03-16 17:02 'wind 阅读(295) 评论(0) 推荐(0)
摘要:Problem Description大家都知道,pfz是“成电杰出学生”,在成电杰出学生的颁奖典礼上,lxh和pfz都没有听台上在说什么,而是在下面讨论当晚的美式足球比赛,lxh预测说纽约巨人队今晚将会得到11分,pfz马上说不可能。因为通常来说美式足球比赛的得分只有3分和7分两种形式,无论怎么得分都不可能得到11分。想了一会以后,lxh发现其实11分以上的分数都是可以得到,于是11就是最大的不可以得到的分数。现在问题来了,如果比赛的得分只有x分和y分两种形式,那么最大的不可以得到的分数是多少呢?Input本题包括多组输入每组输入2个整数x, y(2<=x, y<=10^8),x 阅读全文
posted @ 2012-03-16 17:01 'wind 阅读(229) 评论(0) 推荐(0)
摘要:Problem Description在一无限大的二维平面中,我们做如下假设:1、每次只能移动一格;2、不能向后走(假设你的目的地是“向上”,那么你可以向左走,可以向右走,也可以向上走,但是不可以向下走);3、走过的格子立即塌陷无法再走第二次;求走n步不同的方案数(2种走法只要有一步不一样,即被认为是不同的方案)。Input首先给出一个正整数C,表示有C组测试数据接下来的C行,每行包含一个整数n (n<=20),表示要走n步。Output请编程输出走n步的不同方案总数;每组的输出占一行。Sample Input212Sample Output37分析: 递推式:a[i]=2*a[i-1] 阅读全文
posted @ 2012-03-16 17:00 'wind 阅读(187) 评论(0) 推荐(0)
摘要:Problem Description今年暑假杭电ACM集训队第一次组成女生队,其中有一队叫RPG,但做为集训队成员之一的野骆驼竟然不知道RPG三个人具体是谁谁。RPG给他机会让他猜猜,第一次猜:R是公主,P是草儿,G是月野兔;第二次猜:R是草儿,P是月野兔,G是公主;第三次猜:R是草儿,P是公主,G是月野兔;......可怜的野骆驼第六次终于把RPG分清楚了。由于RPG的带动,做ACM的女生越来越多,我们的野骆驼想都知道她们,可现在有N多人,他要猜的次数可就多了,为了不为难野骆驼,女生们只要求他答对一半或以上就算过关,请问有多少组答案能使他顺利过关。Input输入的数据里有多个case,每个 阅读全文
posted @ 2012-03-16 16:59 'wind 阅读(231) 评论(0) 推荐(0)
摘要:Problem Description小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望。不过没过几天发现了棋盘的好玩之处。从起点(0,0)走到终点(n,n)的最短路径数是C(2n,n),现在小兔又想如果不穿越对角线(但可接触对角线上的格点),这样的路径数有多少?小兔想了很长时间都没想出来,现在想请你帮助小兔解决这个问题,对于你来说应该不难吧!Input每次输入一个数n(1<=n<=35),当n等于-1时结束输入。Output对于每个输入数据输出路径数,具体格式看Sample。Sample Input1312-1Sample Ou 阅读全文
posted @ 2012-03-16 16:59 'wind 阅读(179) 评论(0) 推荐(0)
摘要:Problem Description由于长期缺乏运动,小黑发现自己的身材臃肿了许多,于是他想健身,更准确地说是减肥。小黑买来一块圆形的毯子,把它们分成三等分,分别标上A,B,C,称之为“跳舞毯”,他的运动方式是每次都从A开始跳,每次都可以任意跳到其他块,但最后必须跳回A,且不能原地跳.为达到减肥效果,小黑每天都会坚持跳n次,有天他突然想知道当他跳n次时共几种跳法,结果想了好几天没想出来-_-现在就请你帮帮他,算出总共有多少跳法。Input测试输入包含若干测试用例。每个测试用例占一行,表示n的值(1<=n<=1000)。当n为0时输入结束。Output每个测试用例的输出占一行,由于 阅读全文
posted @ 2012-03-16 16:58 'wind 阅读(767) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-03-16 16:50 'wind 阅读(7) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-03-16 16:08 'wind 阅读(9) 评论(0) 推荐(0)
摘要:要求: 桌上有一叠牌,从上到下一次编号1~n当至少剩两张牌时进行以下操作: 扔掉第一张牌,把新的第一张放到最后,输出扔掉的牌编号和剩下的牌编号sample input:7sample output:1 3 5 7 4 2 6code:View Code #include<stdio.h> const int maxn=100; int queue[maxn]; int main() { int front,rear,i,n; while(scanf("%d",&n)!=EOF) ... 阅读全文
posted @ 2012-03-16 12:51 'wind 阅读(237) 评论(0) 推荐(0)
摘要:要求: 输入输的深度和小球数,输出最后一个小球所在的叶子编号。code:View Code #include<stdio.h> #include<string.h> int s[1<<20]; int main() { int k,d,n,i,I; while(scanf("%d%d",&d,&I)!=EOF) { memset(s,0,sizeof(s)); n=(1<<d)-1; ... 阅读全文
posted @ 2012-03-16 12:50 'wind 阅读(229) 评论(0) 推荐(0)
摘要:DescriptionLittle Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example of one of her creations:D/ \/ \B E/ \ \/ \ \A C G//FTo record her trees for future gene... 阅读全文
posted @ 2012-03-16 12:49 'wind 阅读(185) 评论(0) 推荐(0)
摘要:DescriptionThere is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreover, it turned out that the station could be only a d 阅读全文
posted @ 2012-03-16 12:48 'wind 阅读(225) 评论(0) 推荐(0)
摘要:Description用计算机随机生成了N个0到1000000000(包含0和1000000000)之间的随机整数(N≤5000000),对于其中重复的数字,只保留一个,把其余相同的数去掉。然后再把这些数从小到大排序。请你完成“去重”与“排序”的工作Input输入有2行,第1行为1个正整数,表示所生成的随机数的个数:N第2行有N个用空格隔开的正整数,为所产生的随机数。Output输出也是2行,第1行为1个正整数M,表示不相同的随机数的个数。第2行为M个用空格隔开的正整数,为从小到大排好序的不相同的随机数。Sample Input1020 40 32 67 40 20 89 300 400 15 阅读全文
posted @ 2012-03-16 12:47 'wind 阅读(396) 评论(0) 推荐(0)
摘要:DescriptionThere are six kinds of brackets: ‘(‘, ‘)’, ‘[‘, ‘]’, ‘{’, ‘}’. dccmx’s girl friend is now learning java programminglanguage, and got mad with brackets! Now give you a string of brackets. Is it valid? For example: “(([{}]))” is valid, but“([)]” is not.InputFirst line contains an integer T 阅读全文
posted @ 2012-03-16 12:45 'wind 阅读(218) 评论(0) 推荐(0)
摘要:DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li ≤ 50,000) units. He then purchases a single long board just long enough to saw into the N 阅读全文
posted @ 2012-03-16 12:40 'wind 阅读(177) 评论(0) 推荐(0)
摘要:Description In information theory, a low-density parity-check (LDPC) code is a linear error correcting code, a method of transmitting a message over a noisy transmission channel, and is constructed using a sparse bipartite graph. LDPC codes are capacity-approaching codes, which means that practical 阅读全文
posted @ 2012-03-16 12:39 'wind 阅读(318) 评论(0) 推荐(0)
摘要:Problem DescriptionIn this problem, we assume the positive integer with the following properties are called ‘the special number’:1) The special number is a non-negative integer without any leading zero.2) The numbers in every digit of the special number is unique ,in decimal system.Of course,it is e 阅读全文
posted @ 2012-03-16 12:36 'wind 阅读(572) 评论(0) 推荐(0)
摘要:DescriptionThe game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator.There are 16 handles on the refrigerator door. Every handle can be in one of two states: open or closed. The refrigerator is open only when all handles are open. The handl 阅读全文
posted @ 2012-03-16 12:35 'wind 阅读(180) 评论(0) 推荐(0)
摘要:Description"47 is the quintessential random number," states the 47 society. And there might be a grain of truth in that.For example, the first ten digits of the Euler's constant are:2 7 1 8 2 8 1 8 2 8And what's their sum? Of course, it is 47.You are given a sequence S of integers 阅读全文
posted @ 2012-03-16 12:32 'wind 阅读(554) 评论(0) 推荐(0)
摘要:DescriptionJiaoZhu likes going on adventure! One day, he walks into a big castle, and there is an unique stairway. JiaoZhu finds a board ,it says “The one who want to go upstairs only can go three steps the most once, meaning that you can go 1 or 2 or 3 steps once!”. Now, we have a problem, can you 阅读全文
posted @ 2012-03-16 07:38 'wind 阅读(214) 评论(0) 推荐(0)
摘要:Problem DescriptionFibonacci数列,定义如下:f(1)=f(2)=1f(n)=f(n-1)+f(n-2) n>=3。计算第n项Fibonacci数值。Input输入第一行为一个整数N,接下来N行为整数Pi(1<=Pi<=1000)。Output输出为N行,每行为对应的f(Pi)。Sample Input512345Sample Output11235分析:大数加法模拟。code:View Code #include<stdio.h>#include<string.h>int i;int b[1002][255];void ji 阅读全文
posted @ 2012-03-16 07:32 'wind 阅读(173) 评论(0) 推荐(0)
摘要:Problem DescriptionAs we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many orders that all the trains can get out of the railway.InputThe input contains several test cases. Each test cases consists of a numbe 阅读全文
posted @ 2012-03-16 07:28 'wind 阅读(164) 评论(0) 推荐(0)
摘要:DescriptionOne of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of those numbers.``This supercomputer is great,'' remarked Chip. ``I only wish Timothy were here to see these r 阅读全文
posted @ 2012-03-16 07:26 'wind 阅读(177) 评论(0) 推荐(0)
摘要:Description 《Neon Genesis Evangelion》(中文译名:新世纪福音战士,简称EVA)。《EVA》是表面上是一部机器人动画,但是在剧情的展开手法,内容的深度上,使得一经播出就在日本引发“社会现象”程度的回应。其中涉及大量宗家和哲学的内容,复杂的人物精神分析。让《EVA》超出简单动画作品的高度。成为日本动画史上无法超越的动画之一。 “MAGI System”出自《EVA》,是作品中Nerv组织所使用的大型中央电脑系统。MAGI一词源于圣经,似乎意为东方三贤人,由东方而来朝拜耶稣的三人。该系统由三台分别以东方三贤人命名的独立电脑MELCHIOR 1、BALTHASAR 阅读全文
posted @ 2012-03-16 07:25 'wind 阅读(353) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<string.h> const int maxn = 3000; int f[maxn]; int main() { int i,j,n; scanf("%d",&n); memset(f,0,sizeof(f)); f[0]=1; for(i=2;i<=n;i++) { //乘以i intc=0; for(j=0;j<m... 阅读全文
posted @ 2012-03-16 07:24 'wind 阅读(187) 评论(0) 推荐(0)
摘要:Problem Description杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区。现在8600需要你帮他找一条这样的路线,并且花费越少越好。Input第一行是2个整数N和M(N <= 100, M <= 1000),代表景区的个数和道路的条数。接下来的M行里,每行包括3个整数a,b,c.代表a和b之间有一条通路,并且需要花费c元(c <= 100)。Outp 阅读全文
posted @ 2012-03-16 00:40 'wind 阅读(276) 评论(0) 推荐(0)
摘要:Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能浪费啊,一定要给自己好好的放个假,可是也不能荒废了训练啊,所以草儿决定在要在最短的时间去一个自己想去的地方!因为草儿的家在一个小镇上,没有火车经过,所以她只能去邻近的城市坐火车(好可怜啊~)。I 阅读全文
posted @ 2012-03-16 00:39 'wind 阅读(157) 评论(0) 推荐(0)
摘要:Problem Description有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛。球赛的规则如下:如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能打败C。如果A打败了B,B又打败了C,而且,C又打败了A,那么A、B、C三者都不可能成为冠军。根据这个规则,无需循环较量,或许就能确定冠军。你的任务就是面对一群比赛选手,在经过了若干场撕杀之后,确定是否已经实际上产生了冠军。Input输入含有一些选手群,每群选手都以一个整数n(n<1000)开头,后跟n对选手的比赛结果,比赛结果以一对选手名字(中间隔一空格)表示,前者战胜后者。如果n为0,则表 阅读全文
posted @ 2012-03-16 00:38 'wind 阅读(223) 评论(0) 推荐(0)
摘要:DescriptionYou are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch are of the same color?InputInput is a sequence of lines, each line contains two words, sep 阅读全文
posted @ 2012-03-16 00:37 'wind 阅读(217) 评论(0) 推荐(0)
摘要:Problem Description呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体.Harry已经将他所会的所有咒语都列成了一个表,他想让你帮忙计算一下他是否能完成老师的作业,将一个B(ball)变成一个M(Mouse),你知道,如果他自己不能完成的话,他就只好向Hermione请教,并且被迫听一大堆好好学习的道理.Input测试数据有多组。每组有多行,每行一个单词,仅包括小写字母,是Harry所 阅读全文
posted @ 2012-03-16 00:36 'wind 阅读(144) 评论(0) 推荐(0)
摘要:Problem Description欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1 < N < 1000 )和边数M;随后的M行对应M条边,每行给出一对正整数,分别是该条边直接连通的两个节点的编号(节点从1到N编号)。当N为0时输入结束。Output每个测试用例的输出占一行,若欧拉回路存在则输出1,否则输出0。Sample Input3 31 21 32 33 21 22 30Sample Output10总结:如果图是联 阅读全文
posted @ 2012-03-16 00:34 'wind 阅读(247) 评论(0) 推荐(0)
摘要:Problem DescriptionSome of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us.There is a large number of magnetic plates on every door. Every plat 阅读全文
posted @ 2012-03-16 00:34 'wind 阅读(300) 评论(0) 推荐(0)
摘要:Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在地,M则表示在成都有几条路。N=M=0表示输入结束。接下来M行,每行包括3个整数A,B,C(1<=A,B<=N,1<=C<=1000),表示在 阅读全文
posted @ 2012-03-16 00:33 'wind 阅读(185) 评论(0) 推荐(0)
摘要:DescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code is simply a string of exactly seven lowercase letters (each letter on each 阅读全文
posted @ 2012-03-16 00:31 'wind 阅读(162) 评论(0) 推荐(0)
摘要:Description东北的冬季,尤其是过年的时候,小陈老师喜欢去堆雪人。每个雪人主要由三个雪球构成:大雪球、中雪球、小雪球。他已经准备好了N个雪球,半径分别等于r1, r2, ..., rn。如果要堆一个雪人,就需要三个半径互不相等的雪球。例如:三个雪球的半径为1、2、3,能够用来堆一个雪人。但是半径为2、2、3或者2、2、2的三个雪球就不可以。快帮帮小陈老师,算算他最多能用这些雪球堆多少个雪人。Input对于每组测试数据:第1行,包含一个整数n(1≤n≤100000) — 雪球的数量。第2行,包含n个整数 — 雪球的半径r1, r2, ..., rn (1≤ri≤1000000000)。处 阅读全文
posted @ 2012-03-16 00:29 'wind 阅读(282) 评论(0) 推荐(0)
摘要:DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get back as quickly as possible.Farmer John's field has N (2 <= N <= 1000) landmarks 阅读全文
posted @ 2012-03-15 23:31 'wind 阅读(202) 评论(0) 推荐(0)
摘要:DescriptionN(1 ≤N≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors.The contest is conducted in several head-to-head rounds, each bet 阅读全文
posted @ 2012-03-15 23:29 'wind 阅读(275) 评论(0) 推荐(0)
摘要:Problem Description有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表示队伍的个数,M表示接着有M行的输入数据。接下来的M行数据中,每行也有两个整数P1,P2表示即P1队赢了P2队。Output给出一个符合要求的排名。输出时队伍号之间有空格, 阅读全文
posted @ 2012-03-15 23:28 'wind 阅读(213) 评论(0) 推荐(0)
摘要:Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。每组数据第一行包含两个正整数N和M(0<N<200,0<M<1000),分别代表现有城镇的数目和已修建的道路的数目。城镇分别以0~N-1编号。接下来是M行道路信息。每一行有三个整数A,B,X(0<=A,B<N,A! 阅读全文
posted @ 2012-03-15 23:27 'wind 阅读(201) 评论(0) 推荐(0)
摘要:Problem Description相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米。当然,为了节省资金,只要求实现任意2个小岛之间有路通即可。其中桥的价格为 100元/米。Input输入包括多组数据。输入首先包括一个整数T(T <= 200),代表有T组数据。每组数据首先是一个整 阅读全文
posted @ 2012-03-15 23:26 'wind 阅读(170) 评论(0) 推荐(0)
摘要:DescriptionIn some cultural traditions, giving chocolate as a present on Valentine’s Day is a very traditional symbol of love. LDA does some research on chocolate manufacturing. And luckily, he makes some good quality chocolate bars. In addition, these chocolate bars are very long. They are composed 阅读全文
posted @ 2012-03-15 23:24 'wind 阅读(177) 评论(0) 推荐(0)
摘要:Description既然大家都不愿意做水题,元帅也很无奈,想了好久也不知道什么是水题,因为在元帅的眼里都是水题,他定义的非水题就是他做不出来的题。太囧了,随便弄个水的MST。Input测试输入包含若干测试用例。每个测试用例的第1行给出顶点数目N ( < 100 );随后的N(N-1)/2行对应村庄间的距离,每行给出一对正整数,分别是两个顶点的编号,以及此两村庄间的距离。为简单起见,村庄从1到N编号。当N为0时,输入结束,该用例不被处理。Output对于每个测试用例,输出MST的最小路径总长度。Sample Input31 2 11 3 22 3 441 2 11 3 41 4 12 3 阅读全文
posted @ 2012-03-15 23:21 'wind 阅读(193) 评论(0) 推荐(0)
摘要:DescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.InputThe first line contains two numbers N and Q. 1 ≤ 阅读全文
posted @ 2012-03-15 22:06 'wind 阅读(172) 评论(0) 推荐(0)
摘要:Problem DescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes mo 阅读全文
posted @ 2012-03-15 19:03 'wind 阅读(197) 评论(0) 推荐(0)
摘要:A path with no repeated vertices of an undirected graph is called a simple path. Given an undirected graph and two verteices S and D, return the number of vertics which don't lie on any simple paths between S and D.InputThe input contains multiple test cases.Each case starts with a line of four 阅读全文
posted @ 2012-03-15 13:01 'wind 阅读(315) 评论(0) 推荐(0)
摘要:Problem Description蜘蛛牌是windows xp操作系统自带的一款纸牌游戏,游戏规则是这样的:只能将牌拖到比她大一的牌上面(A最小,K最大),如果拖动的牌上有按顺序排好的牌时,那么这些牌也跟着一起移动,游戏的目的是将所有的牌按同一花色从小到大排好,为了简单起见,我们的游戏只有同一花色的10张牌,从A到10,且随机的在一行上展开,编号从1到10,把第i号上的牌移到第j号牌上,移动距离为abs(i-j),现在你要做的是求出完成游戏的最小移动距离。Input第一个输入数据是T,表示数据的组数。每组数据有一行,10个输入数据,数据的范围是[1,10],分别表示A到10,我们保证每组数 阅读全文
posted @ 2012-03-15 13:00 'wind 阅读(369) 评论(0) 推荐(0)
摘要:Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP" , you will go up Ki floor,i.e,you will go to 阅读全文
posted @ 2012-03-15 13:00 'wind 阅读(184) 评论(0) 推荐(0)
摘要:Description机器人要在一个矩形迷宫里行动(不能原地停留,只能走向上/下/左/右),每移动一格花费1个单位时间。迷宫有以下几种元素:【*】机器人的起点【#】墙。机器人不能走过这些格子【.】平地。机器人可以在上面自由行走【0-9】宝藏。当机器人走到此处会立刻获得该数字相应的宝藏,宝藏不会消失,可以反复获取(但不能停留)若机器人要恰好获得总和为x的宝藏,它最少需要多少时间?Input第一行输入任务数量T,接下来有T个任务每块第一行有两个整数, n(0 <100), m(0 < 100),表示迷宫有n+1行和m+1列接下来n行输入迷宫最后一行输入你要收集的宝藏的总价值x(x≤10 阅读全文
posted @ 2012-03-15 12:59 'wind 阅读(236) 评论(0) 推荐(0)
摘要:Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to shoot. The four openings are facing North, E 阅读全文
posted @ 2012-03-15 12:58 'wind 阅读(173) 评论(0) 推荐(0)
摘要:Problem DescriptionThere is a mountain near yifenfei’s hometown. On the mountain lived a big monster. As a hero in hometown, yifenfei wants to kill it.Now we know yifenfei have n spells, and the monster have m HP, when HP <= 0 meaning monster be killed. Yifenfei’s spells have different effect if 阅读全文
posted @ 2012-03-15 12:57 'wind 阅读(266) 评论(0) 推荐(0)
摘要:Problem DescriptionYou're in space.You want to get home. There are asteroids. You don't want to hit them. InputInput to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank 阅读全文
posted @ 2012-03-15 12:56 'wind 阅读(232) 评论(0) 推荐(0)
摘要:Problem DescriptionZty is a man that always full of enthusiasm. He wants to solve every kind of difficulty ACM problem in the world. And he has a habit that he does not like to solvea problem that is easy than problem he had solved. Now yifenfei give him n difficulty problems, and tell him their rel 阅读全文
posted @ 2012-03-15 12:55 'wind 阅读(221) 评论(0) 推荐(0)
摘要:Problem Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sample Input1850Sample Output19210code :View Code #include<stdio.h>#include<string.h>int tot 阅读全文
posted @ 2012-03-15 12:54 'wind 阅读(197) 评论(0) 推荐(0)
摘要:Problem Description呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体.Harry已经将他所会的所有咒语都列成了一个表,他想让你帮忙计算一下他是否能完成老师的作业,将一个B(ball)变成一个M(Mouse),你知道,如果他自己不能完成的话,他就只好向Hermione请教,并且被迫听一大堆好好学习的道理.Input测试数据有多组。每组有多行,每行一个单词,仅包括小写字母,是Harry所 阅读全文
posted @ 2012-03-15 12:53 'wind 阅读(182) 评论(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 the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 pieces, thus changing the color of t 阅读全文
posted @ 2012-03-15 12:52 'wind 阅读(276) 评论(0) 推荐(0)
摘要:Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want to save Angel. Their task is: approach Angel. We assume that "approach Angel 阅读全文
posted @ 2012-03-15 12:51 'wind 阅读(175) 评论(0) 推荐(0)
摘要:DescriptionBackgroundMr 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 ProblemYour task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from ano 阅读全文
posted @ 2012-03-15 12:50 'wind 阅读(187) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<string.h>int prime[40];int a[20];int vis[20];int n;int isprime(int n){ int i; for(i=2;i*i<=n;i++) if(n%i==0) return 0; return 1;}void dfs(int cur){ int i; if(cur==n&&prime[a[0]+a[n-1]]) //递归边界,最后一个数和第一个数和是质数 { for(i=0;i<n;i++... 阅读全文
posted @ 2012-03-15 12:49 'wind 阅读(139) 评论(0) 推荐(0)
摘要:DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。 阅读全文
posted @ 2012-03-15 12:46 'wind 阅读(142) 评论(0) 推荐(0)
摘要:迷宫问题Time Limit:1000MSMemory Limit:65536KTotal Submissions:3850Accepted:2226Description定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。Output左上角到右下角 阅读全文
posted @ 2012-03-15 12:44 'wind 阅读(333) 评论(0) 推荐(0)
摘要:要求: 输入行数为n列数为m的迷宫,用‘s’表示起点,‘#’表示墙头,输出起点到各点的最短路。sample input:5 5s#....#....#..........#..sample output:0 0 8 9 101 0 7 0 92 0 6 0 83 4 5 6 74 5 0 7 8code:View Code #include<stdio.h> #include<string.h> int dx[4]={-1,0,0,1},dy[4]={0,-1,1,0}; int q[100000]; int maze[200][200]; int vis[200][2 阅读全文
posted @ 2012-03-15 12:36 'wind 阅读(266) 评论(0) 推荐(0)
摘要:DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on the same number line. Farmer John has two modes of transportation: walking and teleporting 阅读全文
posted @ 2012-03-15 12:35 'wind 阅读(196) 评论(0) 推荐(0)
摘要:Problem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using s 阅读全文
posted @ 2012-03-15 12:34 'wind 阅读(177) 评论(0) 推荐(0)
摘要:Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles.Write a program to count 阅读全文
posted @ 2012-03-15 12:34 'wind 阅读(256) 评论(0) 推荐(0)
摘要:View Code #include<stdio.h>#include<string.h>int id,jd,k,t,m,n,f[8]={0,0,1,-1,1,-1,0,0};char s[8][8];void dfs(int i,int j,int c){ int p,ii,jj; if(i==id&&j==jd) { if(c==k) t=1; return; } for(p=0;p<4;p++) { ii=i+f[p]; jj=j+f[p+4]; if(... 阅读全文
posted @ 2012-03-15 12:33 'wind 阅读(195) 评论(0) 推荐(0)
摘要:DescriptionLeyni是一个地址调查员,有一天在他调查的地方突然出现个泉眼。由于当地的地势不均匀,有高有低,他觉得如果这个泉眼不断的向外溶出水来,这意味着这里在不久的将来将会一个小湖。水往低处流,凡是比泉眼地势低或者等于的地方都会被水淹没,地势高的地方水不会越过。而且又因为泉水比较弱,当所有地势低的地方被淹没后,水位将不会上涨,一直定在跟泉眼一样的水位上。 由于Leyni已经调查过当地很久了,所以他手中有这里地势的详细数据。所有的地图都是一个矩形,并按照坐标系分成了一个个小方格,Leyni知道每个方格的具体高度。我们假定当水留到地图边界时,不会留出地图外,现在他想通过这些数据分析出, 阅读全文
posted @ 2012-03-15 12:30 'wind 阅读(361) 评论(0) 推荐(0)
摘要:Problem DescriptionDo you remember the box of Matryoshka dolls last week? Adam just got another box of dolls from Matryona. This time, the dolls have different shapes and sizes: some are skinny, some are fat, and some look as though they were attened. Specifically, doll i can be represented by three 阅读全文
posted @ 2012-03-15 01:00 'wind 阅读(239) 评论(0) 推荐(0)
摘要:Problem Description给你一个n*n的格子的棋盘,每个格子里面有一个非负数。从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大。Input包括多个测试实例,每个测试实例包括一个整数n 和n*n个非负数(n<=20)Output对于每个测试实例,输出可能取得的最大的和Sample Input375 15 21 75 15 28 34 70 5Sample Output188预备知识:点覆盖集:无向图G的一个点集,使得该图中所有边都至少有一个端点在该集合内。最小点权覆盖集:在带点权无向图G中,点权之和最小的覆盖集 阅读全文
posted @ 2012-03-15 00:59 'wind 阅读(242) 评论(0) 推荐(0)
摘要:DescriptionBessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently located at the lattice points of the grid. Fortunately, Bessie has a powerful weapo 阅读全文
posted @ 2012-03-15 00:58 'wind 阅读(230) 评论(0) 推荐(0)
摘要:Problem DescriptionThere are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. But this may not imply that A and C know each other.Now you are given all pairs of students who know each other. Your task is to 阅读全文
posted @ 2012-03-15 00:57 'wind 阅读(256) 评论(0) 推荐(0)
摘要:Problem DescriptionRPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子或伪酷儿做partner。考虑到经费问题,boss刘决定只让找到partner的人去坐过山车,其他的人,嘿嘿,就站在下面看着吧。聪明的Acmer,你可以帮忙算算最多有多少对组合可以坐上过山车吗 阅读全文
posted @ 2012-03-15 00:55 'wind 阅读(245) 评论(0) 推荐(0)
摘要:Problem DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie's favorite clover patch. This means that the clover is covered by water for awhile and takes quite a long time to regrow. Thus, Farmer John has built a set of drainage ditches so that Bessie's clover 阅读全文
posted @ 2012-03-15 00:54 'wind 阅读(207) 评论(0) 推荐(0)
摘要:Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.InputThe first line of input contains an integer T, denoting the number of test cases.For each test case, the first line contains two 阅读全文
posted @ 2012-03-15 00:52 'wind 阅读(233) 评论(0) 推荐(0)
摘要:Problem DescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, your task is to find out the maximum flow for the weighted directed graph.InputThe first line of input contains an integer T, denoting the number of test cases.For each test case, the first line contains two 阅读全文
posted @ 2012-03-15 00:51 'wind 阅读(744) 评论(0) 推荐(0)
摘要:Problem DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.Now Pudge wants to do some operations on the hook.Let us number the consecutive metallic stick 阅读全文
posted @ 2012-03-15 00:49 'wind 阅读(194) 评论(0) 推荐(0)
摘要:Problem DescriptionN个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N)。当N = 0,输入结束。Output每个测试实例输出一行,包括N个整数,第I个数代表第I个气球总共 阅读全文
posted @ 2012-03-15 00:47 'wind 阅读(436) 评论(0) 推荐(0)
摘要:Problem DescriptionAt the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest programming competitions, changes in the dining room menu, and other important inf 阅读全文
posted @ 2012-03-15 00:45 'wind 阅读(200) 评论(0) 推荐(0)
摘要:Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.For a given sequence of numbers a1, a2, ..., an, if we move the first m >= 0 numbers to the end of the seqence, we will obtain another sequence. 阅读全文
posted @ 2012-03-15 00:44 'wind 阅读(204) 评论(0) 推荐(0)
摘要:Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5000 ),分别代表学生的数目和操作的数目。学生ID编号分别从1编到N。第二行包含N个整数,代表这N个学生的初始成绩,其中第i个数代表ID为i的学生的成绩。接下来有M行。每一行有一个 阅读全文
posted @ 2012-03-15 00:42 'wind 阅读(168) 评论(0) 推荐(0)
摘要:Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟演习什么战术,所以Tidy要随时向Derek汇报某一段连续的工兵营地一共有多少人,例如Derek问:“Tidy,马上汇报第3个营地到第10个营地共有多少人!”Tidy就要马上开始计算 阅读全文
posted @ 2012-03-15 00:41 'wind 阅读(182) 评论(0) 推荐(0)
摘要:DescriptionAn array of sizen≤ 106is given to you. There is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers in the window. Each time the sliding window moves rightwards by one position. Following is an example:The array is [13-1 阅读全文
posted @ 2012-03-15 00:34 'wind 阅读(201) 评论(0) 推荐(0)
摘要:DescriptionLeyni被人掳走,身在水深火热之中...小奈叶为了拯救Leyni,独自一人前往森林深处从静竹手中夺回昏迷中的Leyni。历经千辛万苦,小奈叶救出了Leyni,但是静竹为此极为恼怒,决定对他们发起最强烈的进攻。不过小奈叶有一个叫做能量保护圈的道具,可以保护他们。这个保护圈由n个小的小护盾围成一圈,从1到n编号。当某一块小护盾受到攻击的时候,小护盾就会抵消掉这次攻击,也就是说对这一块小护盾的攻击是无效攻击,从而保护圈里的人,不过小护盾在遭到一次攻击后,需要t秒进行冷却,在冷却期间受到的攻击都是有效攻击,此时他们就会遭到攻击, 即假设1秒时受到攻击并成功防御,到1+t秒时冷却 阅读全文
posted @ 2012-03-15 00:31 'wind 阅读(272) 评论(0) 推荐(0)
摘要:DescriptionTigers are enclosed in wire-net fencing at zoo.If they get out of the fencing, they may attack people.We use some lines to present the fencing as the picture following:Your task is to judge if a tiger in the fencing or not.In picture 1 the tiger is in the fencing.Note that enclosed fencin 阅读全文
posted @ 2012-03-15 00:29 'wind 阅读(231) 评论(0) 推荐(0)
摘要:Description一个封闭的多边形定义是被有限个线段包围。线段的相交点称作多边形的顶点,当你从多边形的一个顶点沿着线段行走时,最终你会回到出发点。凸多边形(convex)想必大家已经很熟悉了,下图给出了凸多边形和非凸多边形实例。这里讨论的是在平面坐标的封闭凸多边形,多变形的顶点一个顶点在原点(x=0,y=0).图2显示的那样。这样的图形有两种性质。第一种性质是多边形的顶点会在平面上少于等于三个象限,就如图二那样,第二向县里面没有多边形的点(x<0,y>0)。为了解释第二种性质,假设你沿着多边形旅行,从原点(0,0)出发遍历每个顶点一次,当你遍历到除原点(0,0)时候,从这一点画 阅读全文
posted @ 2012-03-15 00:28 'wind 阅读(334) 评论(0) 推荐(0)
摘要:DescriptionArcheologists from the Antiquities and Curios Museum (ACM) have flown to Egypt to examine the great pyramid of Key-Ops. Using state-of-the-art technology they are able to determine that the lower floor of the pyramid is constructed from a series of straightline walls, which intersect to f 阅读全文
posted @ 2012-03-15 00:27 'wind 阅读(186) 评论(0) 推荐(0)
摘要:DescriptionStan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last thrown stick is always on top but he 阅读全文
posted @ 2012-03-15 00:25 'wind 阅读(225) 评论(0) 推荐(0)
摘要:DescriptionCalculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box to put his toys in, but John is rebellious and obeys his parents by s 阅读全文
posted @ 2012-03-14 23:15 'wind 阅读(185) 评论(0) 推荐(0)
摘要:Problem DescriptionMany geometry(几何)problems were designed in the ACM/ICPC. And now, I also prepare a geometry problem for this final exam. According to the experience of many ACMers, geometry problems are always much trouble, but this problem is very easy, after all we are now attending an exam, no 阅读全文
posted @ 2012-03-14 23:14 'wind 阅读(256) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-03-14 23:13 'wind 阅读(18) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-03-14 23:12 'wind 阅读(10) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2012-03-14 23:10 'wind 阅读(6) 评论(0) 推荐(0)
摘要:Problem DescriptionIn computer vision, a chain code is a sequence of numbers representing directions when following the contour of an object. For example, the following figure shows the contour represented by the chain code 22234446466001207560 (starting at the upper-left corner).Two chain codes may 阅读全文
posted @ 2012-03-14 18:27 'wind 阅读(320) 评论(0) 推荐(0)
摘要:Problem DescriptionIgnatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串.注意:本题只有一组测试数据,处理到文件结束.Output对于每个提问,给出以该字符串为前缀的单词的数量Sample Inputbananabandbeeabsoluteacmba 阅读全文
posted @ 2012-03-14 18:26 'wind 阅读(234) 评论(0) 推荐(0)
摘要:DescriptionA prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "ca", "car", "carb", "carbo", and "carbon". Note that the empty string is not considered a prefix in 阅读全文
posted @ 2012-03-14 18:24 'wind 阅读(260) 评论(0) 推荐(0)
摘要:Problem DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book:Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain 阅读全文
posted @ 2012-03-14 18:23 'wind 阅读(190) 评论(0) 推荐(0)
摘要:Problem Description一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。Output输出能从花纹布中剪出的最多小饰条个数,如果一块都没有,那就老老实实输出0,每个结果之间应换行。Sample Inputabcde a3aaaaaa aa#Sample Output 阅读全文
posted @ 2012-03-14 18:22 'wind 阅读(133) 评论(0) 推荐(0)
摘要:Problem DescriptionGiven two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2], ...... , a[K + M - 1] = b[M]. If there are more than one K exist, ou 阅读全文
posted @ 2012-03-14 18:22 'wind 阅读(177) 评论(0) 推荐(0)
摘要:Problem Description给定一个长度为偶数位的0,1字符串,请编程实现串的奇偶位互换。Input输入包含多组测试数据;输入的第一行是一个整数C,表示有C测试数据;接下来是C组测试数据,每组数据输入均为0,1字符串,保证串长为偶数位(串长<=50)。Output请为每组测试数据输出奇偶位互换后的结果;每组输出占一行。Sample Input201101100Sample Output10011100code:View Code #include<stdio.h>int main(){ int i,t; char s[51]; scanf("%d" 阅读全文
posted @ 2012-03-14 18:20 'wind 阅读(262) 评论(0) 推荐(0)
摘要:DescriptionThere is a straight highway with villages alongside the highway. The highway is represented as an integer axis, and the position of each village is identified with a single integer coordinate. There are no two villages in the same position. The distance between two positions is the absolu 阅读全文
posted @ 2012-03-14 18:10 'wind 阅读(349) 评论(0) 推荐(0)
摘要:Problem Description给你一个n*n的格子的棋盘,每个格子里面有一个非负数。从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大。Input包括多个测试实例,每个测试实例包括一个整数n 和n*n个非负数(n<=20)Output对于每个测试实例,输出可能取得的最大的和Sample Input375 15 2175 15 2834 70 5 Sample Output188分析:主要思想是从第一行到第N行,从第一列到第N列进行DP,用位来保存状态,比如在i行j列,对所有的0到2^n -1 状态进行计算,最后的结果 阅读全文
posted @ 2012-03-14 18:09 'wind 阅读(677) 评论(0) 推荐(0)
摘要:Description在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧。在桥上有一些石子,青蛙很讨厌踩在这些石子上。由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥上青蛙可能到达的点看成数轴上的一串整点:0,1,……,L(其中L是桥的长度)。坐标为0的点表示桥的起点,坐标为L的点表示桥的终点。青蛙从桥的起点开始,不停的向终点方向跳跃。一次跳跃的距离是S到T之间的任意正整数(包括S,T)。当青蛙跳到或跳过坐标为L的点时,就算青蛙已经跳出了独木桥。题目给出独木桥的长度L,青蛙跳跃的距离范围S,T,桥上石子的位置。你的任务是确定青蛙要想过河,最少需要踩到的石子数。Input有 阅读全文
posted @ 2012-03-14 18:08 'wind 阅读(1060) 评论(0) 推荐(0)
摘要:Description在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧。在桥上有一些石子,青蛙很讨厌踩在这些石子上。由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥上青蛙可能到达的点看成数轴上的一串整点:0,1,……,L(其中L是桥的长度)。坐标为0的点表示桥的起点,坐标为L的点表示桥的终点。青蛙从桥的起点开始,不停的向终点方向跳跃。一次跳跃的距离是s到t之间的任意正整数(包括s,t)。当青蛙跳到或跳过坐标为L的点时,就算青蛙已经跳出了独木桥。题目给出独木桥的长度L,青蛙跳跃的距离范围s,t,桥上石子的位置。你的任务是确定青蛙要想过河,最少需要踩到的石子数。Input有 阅读全文
posted @ 2012-03-14 18:07 'wind 阅读(349) 评论(0) 推荐(0)
摘要:Problem Description给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。Input输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y(0<m,n<1000 AND 0<x<=m AND 0<y<=n),表示给定的矩形有m行n列。接下来这个矩阵,有m行,每行有n个不大于1000的正整数。Output对于每组数据,输出一个整数,表示子矩阵的最大和。Sample Input14 5 2 23 361 649 676 588992 762 156 9 阅读全文
posted @ 2012-03-14 18:06 'wind 阅读(505) 评论(0) 推荐(0)
摘要:Problem DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1 x 1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that rectangle. In this problem the sub-rectangle with the 阅读全文
posted @ 2012-03-14 18:04 'wind 阅读(341) 评论(0) 推荐(0)
摘要:Problem DescriptionBean-eating is an interesting game, everyone owns an M*N matrix, which is filled with different qualities beans. Meantime, there is only one bean in any 1*1 grid. Now you want to eat the beans and collect the qualities, but everyone must obey by the following rules: if you eat the 阅读全文
posted @ 2012-03-14 18:03 'wind 阅读(318) 评论(0) 推荐(0)
摘要:Problem DescriptionA number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first 20 humble numbers.Write a program to find and print the nth element in this sequenceInputThe input co 阅读全文
posted @ 2012-03-14 18:02 'wind 阅读(262) 评论(0) 推荐(0)
摘要:Problem DescriptionPirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that if she types a string by some ways, she will type the key at least. But she has a bad habit that if the caps l 阅读全文
posted @ 2012-03-14 18:01 'wind 阅读(554) 评论(0) 推荐(1)
摘要:Problem DescriptionBob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,factories and buildings. There is still some space in the area that is unoccupied. The strategic task o 阅读全文
posted @ 2012-03-14 17:56 'wind 阅读(288) 评论(0) 推荐(0)
摘要:Problem Description都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝,每秒种只有在移动不超过一米的范围内接住坠落的馅饼。现在给这条小径如图标上坐标:为了使问题简化,假设在接下来的一段时间里,馅饼都掉落在0-10这11个位置。开始时 阅读全文
posted @ 2012-03-14 17:56 'wind 阅读(209) 评论(0) 推荐(0)
摘要:Problem DescriptionA histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rectangles with the heights 2, 1, 4, 5, 1, 3, 3, m 阅读全文
posted @ 2012-03-14 17:54 'wind 阅读(322) 评论(0) 推荐(0)
摘要:Problem DescriptionXiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the number written by Xiao Ming is too much, Xiao Bao is feeling giddy. Now, try to help Xiao Bao.InputThere are 阅读全文
posted @ 2012-03-14 17:53 'wind 阅读(440) 评论(0) 推荐(0)
摘要:Problem DescriptionA bee larva living in a hexagonal cell of a large honeycomb decides to creep for a walk. In each “step” the larva may move into any of the six adjacent cells and after n steps, it is to end up in its original cell.Your program has to compute, for a given n, the number of different 阅读全文
posted @ 2012-03-14 17:52 'wind 阅读(819) 评论(0) 推荐(0)
摘要:Problem Description穿过幽谷意味着离大魔王lemon已经无限接近了!可谁能想到,yifenfei在斩杀了一些虾兵蟹将后,却再次面临命运大迷宫的考验,这是魔王lemon设下的又一个机关。要知道,不论何人,若在迷宫中被困1小时以上,则必死无疑!可怜的yifenfei为了去救MM,义无返顾地跳进了迷宫。让我们一起帮帮执着的他吧!命运大迷宫可以看成是一个两维的方格阵列,如下图所示:yifenfei一开始在左上角,目的当然是到达右下角的大魔王所在地。迷宫的每一个格子都受到幸运女神眷恋或者痛苦魔王的诅咒,所以每个格子都对应一个值,走到那里便自动得到了对应的值。现在规定yifenfei只能 阅读全文
posted @ 2012-03-14 17:51 'wind 阅读(207) 评论(0) 推荐(0)
摘要:Problem Description搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不大于n的整数.幸运的是xhd根据多年的搬东西的经验发现每搬一次的疲劳度是和左右手的物品的重量差的平方成正比(这里补充一句,xhd每次搬两件东西,左手一件右手一件).例如xhd左手拿重量为3的物品,右手拿重量为6的物品,则他搬完这次的疲劳度为(6-3)^2 = 9.现在可怜的xh 阅读全文
posted @ 2012-03-14 17:49 'wind 阅读(291) 评论(0) 推荐(0)
摘要:Description前段时间,某省发生干旱,B山区的居民缺乏生活用水,现在需要从A城市修一条通往B山区的路。假设有A城市通往B山区的路由m条连续的路段组成,现在将这m条路段承包给n个工程队(n≤m≤ 300)。为了修路的便利,每个工程队只能分配到连续的若干条路段(当然也可能只分配到一条路段或未分配到路段)。假设每个工程队修路的效率一样,即每修长度为1的路段所需的时间为1。现在给出路段的数量m,工程队的数量n,以及m条路段的长度(这m条路段的长度是按照从A城市往B山区的方向依次给出,每条路段的长度均小于1000),需要你计算出修完整条路所需的最短的时间(即耗时最长的工程队所用的时间)。Inpu 阅读全文
posted @ 2012-03-14 17:48 'wind 阅读(448) 评论(0) 推荐(0)
摘要:DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。 阅读全文
posted @ 2012-03-14 17:46 'wind 阅读(208) 评论(0) 推荐(0)
摘要:DescriptionAn array of sizen≤ 106is given to you. There is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers in the window. Each time the sliding window moves rightwards by one position. Following is an example:The array is [13-1 阅读全文
posted @ 2012-03-14 17:43 'wind 阅读(211) 评论(0) 推荐(0)
摘要:DescriptionSome of Farmer John'sNcows (1 ≤N≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the top of other cows' heads.Each cowihas a specified heighthi(1 ≤hi≤ 1,000,000,000) and is stan 阅读全文
posted @ 2012-03-14 17:42 'wind 阅读(591) 评论(0) 推荐(0)
摘要:Problem DescriptionNowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now.The game can be played by two or more than two players. It consists of a chessboard(棋盘)and some 阅读全文
posted @ 2012-03-14 17:40 'wind 阅读(338) 评论(0) 推荐(0)
摘要:Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a strictly increasing sequence <i1, i2, ..., ik&g 阅读全文
posted @ 2012-03-14 17:39 'wind 阅读(937) 评论(0) 推荐(0)
摘要:DescriptionGiven a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below:Your task is to calculate d(A).InputThe input consists of T(<=30) test cases. The number of test cases (T) is given in the first line of the input.Each test case contains two lines. The first line is an i 阅读全文
posted @ 2012-03-14 17:34 'wind 阅读(1106) 评论(0) 推荐(0)
摘要:Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.InputThe first line of the input contains an integer T(1<=T<=20) which means the number 阅读全文
posted @ 2012-03-14 17:32 'wind 阅读(765) 评论(0) 推荐(0)
摘要:Description"47 is the quintessential random number," states the 47 society. And there might be a grain of truth in that.For example, the first ten digits of the Euler's constant are:2 7 1 8 2 8 1 8 2 8And what's their sum? Of course, it is 47.You are given a sequence S of integers 阅读全文
posted @ 2012-03-14 17:22 'wind 阅读(452) 评论(0) 推荐(0)
摘要:Problem Description世界杯结束了,意大利人连本带利的收回了法国人6年前欠他们的债,捧起了大力神杯,成就了4星意大利.世界杯虽然结束了,但是这界世界杯给我们还是留下许多值得回忆的东西.比如我们听到了黄名嘴的3分钟激情解说,我们懂得了原来可以向同一个人出示3张黄牌,我们还看到了齐达内的头不仅能顶球还能顶人…………介于有这么多的精彩,xhd决定重温德国世界杯,当然只是去各个承办世界杯比赛的城市走走看看.但是这需要一大比钱,幸运的是xhd对世界杯的热爱之情打动了德国世界杯组委会,他们将提供xhd在中国杭州和德国任意世界杯承办城市的往返机票,并说服了这些城市在xhd到达这座城市时为他提 阅读全文
posted @ 2012-03-14 17:20 'wind 阅读(251) 评论(0) 推荐(0)
摘要:Description一年一度的哈理工选美大赛开始了.来自各个院系的N个美女们都在一起排成一排,然后从左到右给他们标号(1-N),评委叫兽开始观摩,由于身高高低都不同, 叫兽想从中选出尽可能多的人使得他们的身高从左到右依次递增,你能帮助叫兽吗?Input输入数据第一行一个数据表示美女的个数N(0接下来有N个数据表示1-N标号的美女的身高,身高范围都在0-180之内当N=0时候输入结束Output按照样例输出,首先The number is N:N是选出最多美女个数,然后后面输出N个数,代表选出美女的标号,从左到右依次输出.题目保证答案唯一Sample Input32 1 231 2 30Sam 阅读全文
posted @ 2012-03-14 14:55 'wind 阅读(301) 评论(0) 推荐(0)
摘要:Problem Description某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统.Input输入若干组数据.每组数据包括:导弹总个数(正整数),导弹依此飞来的高度(雷达给出的高度数据是不大于30000的正整数,用空格分隔)Output对应每组数据 阅读全文
posted @ 2012-03-14 14:53 'wind 阅读(239) 评论(0) 推荐(0)
摘要:转自:// Blog:www.WuTianQi.com最长上升子序列 LIS(Longest Increasing Subsequence)引出:问题描述:给出一个序列a1,a2,a3,a4,a5,a6,a7….an,求它的一个子序列(设为s1,s2,…sn),使得这个子序列满足这样的性质,s1<s2<s3<…<sn并且这个子序列的长度最长。输出这个最长的长度。(为了简化该类问题,我们将诸如最长下降子序列及最长不上升子序列等问题都看成同一个问题,其实仔细思考就会发现,这其实只是<符号定义上的问题,并不影响问题的实质)例如有一个序列:1 7 3 5 9 4 8,它的 阅读全文
posted @ 2012-03-14 14:49 'wind 阅读(954) 评论(0) 推荐(1)
摘要:Problem Description电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input多组数据。对于每组数据:第一行为正整数n,表示菜的数量。n<=1000。第二行包括n个正整数,表示每种菜的价格。价格不超过50。第三行包括一个正整数m,表示卡上的余额。m<=1000。n=0表示数据结束。Ou 阅读全文
posted @ 2012-03-14 14:16 'wind 阅读(267) 评论(0) 推荐(0)
摘要:Problem DescriptionNowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Computer College and Software College in 2002.The splitting is absolutely a big event in HDU! At the same time, it is a troubl 阅读全文
posted @ 2012-03-14 14:14 'wind 阅读(334) 评论(0) 推荐(0)
摘要:Problem DescriptionSpeakless很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了。要申请国外的任何大学,你都要交纳一定的申请费用,这可是很惊人的。Speakless没有多少钱,总共只攒了n万美元。他将在m个学校中选择若干的(当然要在他的经济承受范围内)。每个学校都有不同的申请费用a(万美元),并且Speakless估计了他得到这个学校offer的可能性b。不同学校之间是否得到offer不会互相影响。“I NEED A OFFER”,他大叫一声。帮帮这个可怜的人吧,帮助他计算一下,他可以收到至少一份offer的最大概率。(如果 阅读全文
posted @ 2012-03-14 14:12 'wind 阅读(254) 评论(0) 推荐(0)
摘要:Problem Description最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他能升掉这最后一级吗?Input输入数据有多组,对于每组数据第一行输入n,m,k,s(0 < n,m,k,s < 100)四个正整数。分别表示还需的经验值,保留的忍耐度,怪的种数和最 阅读全文
posted @ 2012-03-14 14:09 'wind 阅读(1173) 评论(0) 推荐(0)
摘要:Problem DescriptionWhuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in a nearby shop. He wanted to pay the exact price(without change) and he known the price would not more th 阅读全文
posted @ 2012-03-14 14:06 'wind 阅读(457) 评论(0) 推荐(0)
摘要:DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the marbles had the same value, because then they could just split the collection in half. But unfortunately, some 阅读全文
posted @ 2012-03-14 14:02 'wind 阅读(236) 评论(0) 推荐(0)
摘要:Problem Description为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?Input输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(1<=n<=100, 1<=m<=100),分别表示经费的金额和大米的种类,然后是m行数据,每行包含3个数p,h和c(1<=p<=20,1<=h<=200,1<=c<=20),分别表示每袋的价 阅读全文
posted @ 2012-03-14 14:00 'wind 阅读(305) 评论(0) 推荐(0)
摘要:DescriptionDota中英雄技能攻击会有一个范围,现在释放一个技能给出他的攻击范围和目标英雄的位置,问是否能攻击到。攻击范围保证是一个多边型。Input有多组测试数据第一行输入1个整数n,期中n代表攻击范围是给出的n个点组成的多边形,按照时针方向(顺或逆)依次给出,(n>=3)N = 0输入结束。第二行a,b表示目标英雄的坐标( 0 < a,b<100)接下来有n行,每行两个整数x,y(0 < x,y <100)表示每个点的坐标攻击范围在边缘也算在内Output每组结果输出占一行如果能够攻击到输出”Yes”否则输出”No”Sample Input31 14 阅读全文
posted @ 2012-03-14 13:05 'wind 阅读(189) 评论(0) 推荐(0)
摘要:Descriptiondccmx likes playing Warcraft III. Now, he is teaching his girlfriend to play it. In Warcraft III, there are many kinds of units. Every unit costs some gold and lumber. Different units have different attack value.Now question comes. Given some amount of gold and a list of types of units, h 阅读全文
posted @ 2012-03-14 07:37 'wind 阅读(289) 评论(0) 推荐(0)
摘要:Problem DescriptionThe bone collector had a big bag with a volume of V ,and along his trip of collecting there are a lot of bones , obviously , different bone has different value and different volume, now given the each bone’s value along his trip , can you calculate out the maximum of the total val 阅读全文
posted @ 2012-03-14 07:30 'wind 阅读(389) 评论(0) 推荐(0)