摘要:Maximum sumTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u 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 t
阅读全文
摘要:Common SubsequenceTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u 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
阅读全文
摘要:Testing the CATCHERTime Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u DescriptionA military contractor for the Department of Defense has just completed a series of preliminary tests for a new defensive missile called the CATCHER which is capable of intercepting multiple incomin
阅读全文
摘要:CoinsTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u 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 th
阅读全文
摘要:Space ElevatorTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which to build the
阅读全文
摘要:The London Olympic GamesDescription 伦敦奥运会正在如火如荼的进行着,孙扬觉得他们总是游直线有点单调,于是向奥组委提议说,把赛道的隔离物全部拿走,在游泳池中固定一定数量的浮球,某些浮球之间可以直达,球球之间有一定的距离;某些浮球之间不可以直达。选手可以选择从任意一球出发,用最短的时间触摸到所有的浮球的那个就获得冠军(在这里为了使问题简化,如果多次在两个球之间来回的游,我们只计算一次的时间,比如从a球游到b球经过一次,又从b球游到a球,第二次经过相同的路径,但是我们只计算一次。)。真没想到奥组委竟然同意了,并说在下一届奥运会巴西奥运会上将首次加入该比赛。为...
阅读全文
摘要:实验室和食堂Description2012新的暑期集训开始了,一切都还相当不错,但是有一个问题成为了同学们的难题,那就是从实验室到食堂时,天气是非常的炎热,以至于大家都尽量避免从没有遮阴的地方走过,但是某些路径又不得不从没有遮阴的地方走过,所以现在难题出来了,给予你一些单向路段,让你找出从实验室到食堂,晒太阳最少的路径长度,以及该条路径的总长度。如果存在多条最少晒太阳的路径,则总长度要求最短。Input输入n和m,表明是有n<=1000个转折点,m条路径,然后输入m(m<=100000)条路径,每一条路径包括4个数据,s,e,dis1,dis2,分别表示该条路径的起点,终点,路径总
阅读全文
摘要:拼图Description给你1x2、2x1和2x2,3种矩形若干,请你计算出把它们放入2xn的矩形中,一共有多少方法?Input输入有多组测试数据没行输入一个整数n , 3<=n<=20.Output输出能填满这个矩形的方法总数Sample Input3 4Sample Output511【解法一】//DFS思想# include<stdio.h># include<string.h>int dir1[2][2]={{0,1},{1,0}};int vis[2][30];int cnt,ms,st,en;int n;int judge(){ int i,j
阅读全文
摘要:“生化武器”Description在一个封闭的房间里,gogo给大家表演了他的屁遁术,人果然一下没影了,但是他留下的“生化武器”,却以每秒1米的速度向上下左右扩散出去。为了知道自己会不会被“毒”到,你果断写了个算法计算出了“毒气”在t秒时间内可以到达的所有地方。Input有多组测试数据第一行输入n,m,t(0<n,m<=30)n和m表示图的行和列,t表示时间 ,‘*’为表演的地点,‘X’是墙,‘.’为空白的地方Output如果在t秒时间内毒气没有充满房间或刚好充满,输出现在房间里的情况,‘#’表示有‘毒气’的地方否则,输出“No”每组数据输出后有一个空行Sample Input9
阅读全文
摘要:Stock ExchangeTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u DescriptionThe world financial crisis is quite a subject. Some people are more relaxed while others are quite anxious. John is one of them. He is very concerned about the evolution of the stock exchange. He follow
阅读全文
摘要:Longest Ordered SubsequenceTime Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u DescriptionA numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1, a2, ..., aN) be any sequence (ai1, ai2, ..., aiK), where 1 <= i
阅读全文
摘要:滑雪Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u DescriptionMichael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 813 12 11 10 9一个人可以从某个点滑向上下左右相邻四个
阅读全文
摘要:Max SumDescriptionGiven 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 o
阅读全文
摘要:FriendTime Limit:1000MSMemory Limit:65535KBSubmissions:102Accepted:10Description每个人都有朋友,朋友也有很多种,比如:石友--情谊坚贞的朋友。挚友--志同道合的朋友。益友--于己有帮助的朋友。网友--在互联网结识的朋友。闺友--闺房中无话不谈的朋友。君子交:指道义之交,即在道义上相互支持的朋友。竹马之交:少年时骑竹马为戏的朋友,指自幼相交的朋友,等等。现在dearway定义如果王二和张三是朋友,李四和张三也是朋友,那么王二和李四也是朋友,即朋友具有传递关系。现在给你N种朋友关系,问你有多种朋友集合,这些集合里不会出
阅读全文
摘要:How many rounds of winning描述When douglasren came home,he reunioned with his classmates.So M students arrived at the scene. So long they did not see each other,they were very pleased.Then,they decided to play a card game to promote their feelings.At the beginning ,each player receives N cards.All the
阅读全文
摘要:Jungle RoadsTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u DescriptionThe Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the
阅读全文
摘要:Saving James BondTime Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u DescriptionThis time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of drug dealers. He was sent to a small
阅读全文
摘要:畅通工程续Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。每组数据第一行包含两个正整数N和M(0<N<200,0<M<1000),分别代表现有城
阅读全文
摘要:ZipperTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u DescriptionGiven three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitrarily, but each must stay in its o
阅读全文
摘要:The Triangle Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Description73 88 1 02 7 4 44 5 2 6 5(Figure 1)Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on a route that starts at the top and ends somewher...
阅读全文
摘要:SudokuTime Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u DescriptionSudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3 as shown on the Figure. In some of the cells are written decimal digits from 1 to 9. The other cells ar
阅读全文
摘要:OrdersTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u DescriptionThe stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the kinds having labels starting with the same letter are stored in the same warehouse (i.e. in the same building)
阅读全文
摘要:ArbitrageDescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 French francs, and 1 French franc buys 0.21 .
阅读全文
摘要:二叉树的建立和遍历Description建立以二叉链作为存储结构的二叉树,实现 1)先序遍历; 2)中序遍历; 3)后序遍历; 4)层序遍历; 5)编程计算二叉树的叶子结点个数。Input按照先序遍历序列输入二叉树中数据元素的值,没有的输入0表示。Output第一行输出先序遍历序列 第二行输出中序遍历序列 第三行输出后序遍历序列 第四行输出叶子结点的个数。Sample InputA B C 0 0 0 D E 0 F 0 0 G 0 0 Sample OutputA B C D E F G C B A E F D G C B F E G D A 3分析:先认识先序、中序、后序的意思,即可# .
阅读全文
摘要:MPI MaelstromDescriptionBIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advisor, Jack Swigert, has asked her to benchmark the new system. ``Since th
阅读全文
摘要:Additive equationsDescriptionWe all understand that an integer set is a collection of distinct integers. Now the question is: given an integer set, can you find all its addtive equations? To explain what an additive equation is, let's look at the following examples: 1+2=3 is an additive equation
阅读全文
摘要:ExponeniationDescriptionFlip 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 t
阅读全文
摘要:PotsDescriptionYou 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 (an
阅读全文