摘要:Edit DistanceTime Limit:1000MSMemory Limit:65535KBSubmissions:1320Accepted:268Description设A 和B 是2 个字符串。要用最少的字符操作将字符串A 转换为字符串B。这里所说的字符操作包括 (1)删除一个字符; (2)插入一个字符; (3)将一个字符改为另一个字符。 将字符串A变换为字符串B 所用的最少字符操作数称为字符串A到B 的编辑距离,记为d(A,B)。试设计一个有效算法,对任给的2 个字符串A和B,计算出它们的编辑距离d(A,B)。Input第一行是字符串A,文件的第二行是字符串B。字符串长度不大于2
阅读全文
摘要:合并果子(续)前面说过一种合并果子是任意型的http://www.cnblogs.com/jiangjun/archive/2012/11/11/2765474.html下面来看两种类型:直线型和圆形型一、直线型问题描述: 在一个直线上依次摆放N堆石(N≤100),现要将石子有次序地合并成一堆。规定每次只能选相邻的两堆合并成新的一堆,并将新的一堆的石子数,记为该次合并的得分。输入:堆数N及每堆的石子数(≤20),选择一种合并石子的方案,使得做N-1次合并,得分的总和最小(或最大)分析:和矩阵连乘类似,不能像任意型那样用贪心,那用DP求解状态转移方程如下:f[i][j]为第i堆石子到第j堆石子合
阅读全文
摘要:Lucifer's Pyramid of Numbers时间限制:1000ms 内存限制:65535kB描述Lucifer has a strange hobby, he sometimes put offending evils to the Pyramid of Numbers (PoN), and then decides whether he will liberate the evils or not through a game.In PoN, the poor evil could only move straightly down or bottom-right ste
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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...
阅读全文