
dp
xiaofang3a
这个作者很懒,什么都没留下…
展开
-
编辑距离
Problem Description设A和B是两个字符串。我们要用最少的字符操作次数,将字符串A转换为字符串B。这里所说的字符操作共有三种:(1) 删除一个字符(2) 插入一个字符(3) 将一个字符改为另一个字符Input有多组输入数据,每组数据的第一行为字符串A,第二行为字符串B,字符串A和B的长度均小于200.Output对于每组数据输出一个正整数,为最少字符原创 2014-07-14 19:44:48 · 398 阅读 · 0 评论 -
搭配购买(01背包+并查集)
Problem DescriptionJoe觉得云朵很美,决定去山上的商店买一些云朵。商店里有n朵云,云朵被编号为1,2,...,n,并且每朵云都有一个价值。但是商店老板跟他说,一些云朵要搭配来买才好,所以买一朵云则与这朵云有搭配的云都要买。但是Joe的钱有限,所以他希望买的价值越多越好。Input输入有多组数据,每组数据第1行n(=5000)、w(第2至n+1行,每行ci、di表原创 2014-09-16 21:56:24 · 1094 阅读 · 0 评论 -
Dividing
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转载 2014-09-14 22:49:34 · 363 阅读 · 0 评论 -
Minimal——dp
Problem DescriptionThere are two sets S1 and S2 subjecting to:(1) S1, S2 are both the subsets of {x | x is an integer and 0 (2) 0 F(S1 ,S2) = min {|a1-b1| + |a2 – b2| + … + | aN –bN |}in whi原创 2014-08-15 15:24:06 · 404 阅读 · 0 评论 -
Bone Collector(01背包)
Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave原创 2014-09-19 20:56:27 · 353 阅读 · 0 评论 -
ACboy needs your help(分组背包)
Problem DescriptionACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course depending on the days he spend on it.How to ar原创 2014-09-19 20:22:44 · 359 阅读 · 0 评论 -
Find Metal Mineral
Problem DescriptionHumans have discovered a kind of new metal mineral on Mars which are distributed in point‐like with paths connecting each of them which formed a tree. Now Humans launches k robots原创 2014-08-08 21:21:50 · 814 阅读 · 0 评论 -
The more, The Better
Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?Input每个测试实例首先包括2个整数,N,M.(1 =原创 2014-08-08 10:12:37 · 423 阅读 · 0 评论 -
Starship Troopers--树形dp
Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists of many rooms connected w原创 2014-08-19 19:48:03 · 314 阅读 · 0 评论 -
橱窗布置
Problem Description假设以最美观的方式布置花店的橱窗,有F束花,每束花的品种都不一样,同时,至少有同样数量的花瓶,被按顺序摆成一行,花瓶的位置是固定的,并从左到右,从1到V顺序编号,V是花瓶的数目,编号为1的花瓶在最左边,编号为V的花瓶在最右边,花束可以移动,并且每束花用1到F的整数唯一标识,标识花束的整数决定了花束在花瓶中列的顺序即如果I例如,假设杜鹃花的标识数为1,秋原创 2014-08-07 16:12:52 · 395 阅读 · 0 评论 -
Watch The Movie
Problem DescriptionNew semester is coming, and DuoDuo has to go to school tomorrow. She decides to have fun tonight and will be very busy after tonight. She like watch cartoon very much. So she want原创 2014-07-31 09:46:23 · 441 阅读 · 0 评论 -
Anniversary party
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 superviso原创 2014-07-31 09:38:29 · 362 阅读 · 0 评论 -
The Triangle
描述73 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 somewh原创 2014-07-11 12:15:45 · 309 阅读 · 0 评论 -
最长公共子序列
Problem Description一个给定序列的子序列是在该序列中删去若干元素后得到的序列。确切地说,若给定序列X=,则另一个序列Z=是X的子序列是指存在一个严格递增的下标序列,使得对于所有j=1,2,...,k有:Xij=Zj例如,序列Z=是序列X=的子序列,相应的递增下标序列为。给定两个序列X和Y,当另一个序列Z既是X的子序列又是Y的子序列时,称Z是序列X和Y的公共子序列。例如,若原创 2014-07-25 15:07:37 · 355 阅读 · 0 评论 -
开心的小明
描述小明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过N 元钱就行”。今天一早小明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的N 元。于是,他把每件物品规定了一个重要度,分为5 等:用整数1~5 表示,第5 等最重要。他还从因特网上查到了每件物品的价格(都是整原创 2014-07-04 22:21:15 · 348 阅读 · 0 评论 -
回文字符串
描述所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba"。当然,我们给你的问题不会再简单到判断一个字符串是不是回文字符串。现在要求你,给你一个字符串,可在任意位置添加字符,最少再添加几个字符,可以使这个字符串成为回文字符串。输入第一行给出整数N(0接下来的N行,每行一个字符串,每个字符串长度不超过1000.输出每行输出所需添加的最少字符数样原创 2014-07-02 02:29:55 · 429 阅读 · 0 评论 -
方格取数
Problem Description设有N*N的方格中,我们在其中的某些方格中填入正整数,而其他的方格中则放入数字0,如下表所示:0 0 0 0 0 0 0 00 0 13 0 0 6 0 00 0 0 0 7 0 0 00 0 0 14 0 0 0 00 21 0 0 0 4 0 00 0 15 0 0 0 0 00 14 0 0 0 0 0 00 0 0原创 2014-07-18 12:56:21 · 447 阅读 · 0 评论 -
数字游戏 (dp)
Problem Description丁丁最近沉迷于一个数字游戏。这个游戏看似简单,但丁丁在研究了很多天之后却发觉原来在简单的规则下想要赢得这个游戏并不那么容易。游戏是这样的,在你面前有一圈整数(一共n个),你要按顺序将其分为m个部分,各部分内的数字相加,相加后得的m个结果对10取模后再相乘,最终得到一个数k。游戏的要求是使你得到的k最大或者最小。注意:无论是负数还是正数,对10取模的结果均为原创 2014-10-08 19:40:42 · 908 阅读 · 0 评论