DP
文章平均质量分 81
Lionel_D
这个作者很懒,什么都没留下…
展开
-
poj 2533 Longest Ordered Subsequence 深夜再来一波DP
A 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 <= i1 < i2 < ... < iK <= N. For example, sequence (1, 7, 3, 5, 9, 4, 8) has ordered原创 2015-02-08 20:01:19 · 879 阅读 · 0 评论 -
hdu 1574 RP问题 动态规划,01背包的变形
Problem Description在人类社会中,任何个体都具有人品,人品有各种不同的形式,可以从一种形式转换为另一种形式,从一个个体传递给另一个个体,在转换和传递的过程中,人品不会消失,也不被能创造,这就是,人品守恒定律!人品守恒定律更形象的描述,当发生一件好事,你从中获利,必定消耗一定量RP;当发生一件不幸的事,你在其中有所损失,必定积攒一定量RP。假设在一个时间段内在你身上可能会发生N个事件,每个事件都对应一个RP变化值a、RP门槛值b和获益值c。当RP变化值a为正,获益值c必定为负,只有你当原创 2015-03-06 19:35:50 · 1034 阅读 · 0 评论 -
hdu1159 Common Subsequence 最长公共子串
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 increasi原创 2015-03-06 19:46:34 · 835 阅读 · 0 评论 -
hdu 1500 Chopsticks 动态规划 比较经典
Problem DescriptionIn China, people use a pair of chopsticks to get food on the table, but Mr. L is a bit different. He uses a set of three chopsticks -- one pair, plus an EXTRA long chopstick to get some big food by piercing it through the food. As you m原创 2015-03-17 20:09:48 · 1988 阅读 · 0 评论 -
hdu2082 找单词 母函数+完全背包两种算法AC。。数据较水
Problem Description假设有x1个字母A, x2个字母B,..... x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,..... 字母Z的价值为26。那么,对于给定的字母,可以找到多少价值<=50的单词呢?单词的价值就是组成一个单词的所有字母的价值之和,比如,单词ACM的价值是1+3+14=18,单词HDU的价值是8+4+21=33。(组成的单词与排列顺序无关,比如ACM与CMA认为是同一个单词)。 Input输入首先是一个整数N,代表测试实例的个数。然后包括N行数据原创 2015-03-29 14:36:33 · 983 阅读 · 0 评论 -
hdu 3449 Consumer 依赖背包~~
Problem DescriptionFJ is going to do some shopping, and before that, he needs some boxes to carry the different kinds of stuff he is going to buy. Each box is assigned to carry some specific kinds of stuff (that is to say, if he is going to buy one of the原创 2015-03-22 22:23:54 · 917 阅读 · 0 评论 -
hdu 4508 湫湫系列故事——减肥记I 完全背包。
Problem Description 对于吃货来说,过年最幸福的事就是吃了,没有之一! 但是对于女生来说,卡路里(热量)是天敌啊! 资深美女湫湫深谙“胖来如山倒,胖去如抽丝”的道理,所以她希望你能帮忙制定一个食谱,能使她吃得开心的同时,不会制造太多的天敌。 当然,为了方便你制作食谱,湫湫给了你每日食物清单,上面描述了当天她想吃的每种食物能带给她的幸福程度,以及会增加的卡路里量。 Input 输入包含多组测试用例。 每组数据以一个整数n开始,表示每天的食物清单有n种食物。原创 2015-03-22 15:34:36 · 1312 阅读 · 0 评论 -
hdu 3535 AreYouBusy 多重背包~~二进制优化
Problem DescriptionHappy New Term!As having become a junior, xiaoA recognizes that there is not much time for her to AC problems, because there are some other things for her to do, which makes her nearly mad.What's more, her boss tells her that for some原创 2015-03-23 12:04:02 · 1218 阅读 · 0 评论 -
hdu 3591 The trouble of Xiaoqian 多重背包+完全背包。。。
Problem DescriptionIn the country of ALPC , Xiaoqian is a very famous mathematician. She is immersed in calculate, and she want to use the minimum number of coins in every shopping. (The numbers of the shopping include the coins she gave the store and the原创 2015-03-23 19:49:38 · 829 阅读 · 0 评论 -
hdu3127 WHUgirls 残忍的完全背包。。。比较有意思,,物品的那层循环放在最里面
Problem DescriptionThere are many pretty girls in Wuhan University, and as we know, every girl loves pretty clothes, so do they. One day some of them got a huge rectangular cloth and they want to cut it into small rectangular pieces to make scarves. But d原创 2015-03-24 17:12:47 · 996 阅读 · 0 评论 -
hdu 1864 最大报销额 01背包变形
Problem Description现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最大报销额。 Input测试输入包含若干测试用例。每个测试用例的第1行包含两个正数 Q 和 N,其中 Q 是给定的报销额度,N(<=30)是发票张数。随后是 N 行输入,每行的格式为:m Type_1:price原创 2015-03-24 21:11:23 · 962 阅读 · 0 评论 -
hdu 2069 Coin Change 背包。本来打算用母函数再写一遍的,发现代码极其相似,就没写
Problem DescriptionSuppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.For example, if we have 11 cents, then we can make changes with one 10-cent coin a原创 2015-04-08 15:16:19 · 1022 阅读 · 0 评论 -
hdu 1284 钱币兑换问题 完全背包之方案总数~
在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。 Input每行只有一个正整数N,N小于32768。 Output对应每个输入,输出兑换方法数。原创 2015-02-10 19:00:03 · 1099 阅读 · 0 评论 -
hdu 1059 Dividing DP,多重背包 测试数据很水
Marsha 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原创 2015-02-11 20:51:11 · 1622 阅读 · 0 评论 -
hdu 1231 最大连续子序列 DP
给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 <= i <= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个, 例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和 为20。原创 2015-02-08 14:33:44 · 1074 阅读 · 0 评论 -
hdu1024 Max Sum Plus Plus
Problem DescriptionNow I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem.Given a consecutive number sequence S1, S原创 2015-02-07 21:39:04 · 1108 阅读 · 0 评论 -
hdu 1087 Super Jumping! Jumping! Jumping! 最大上升子序列。模板题
Nowadays, 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原创 2015-02-08 18:40:45 · 1976 阅读 · 0 评论 -
hdu 1029 Ignatius and the Princess IV
Problem Description"OK, you are not too bad, em... But you can never pass the next test." feng5166 says."I will tell you an odd number N, and then N integers. There will be a special integer among them, you have to tell me which integer is the special o原创 2015-02-08 11:35:21 · 1228 阅读 · 0 评论 -
hdu 1423 Greatest Common Increasing Subsequence 最大公共上升子序列 DP
Problem DescriptionThis is a problem from ZOJ 2432.To make it easyer,you just need output the length of the subsequence. InputEach sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence i原创 2015-02-09 13:34:40 · 876 阅读 · 0 评论 -
hdu 1069 Monkey and Banana 再来一波DP啦~~LIS的变形,会最大上升子序列就可以A啦~
A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey with some blocks. If the monkey is clever enough, it shall be able to reach the banan原创 2015-02-09 20:49:41 · 1585 阅读 · 0 评论 -
hdu 1025 Constructing Roads In JGShining's Kingdom 深夜又一波DP,最长上升子序列(O(nlogn)算法)!尼玛坑爹的输出啊!!
JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines.Half of these cities are rich in resource (we call them rich cities) while the others are short of resource (we call them poor cities). Eac原创 2015-02-09 22:27:45 · 805 阅读 · 0 评论 -
hdu 2639 Bone Collector II 01背包问题 求第K大最优值。。
Problem DescriptionThe title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't seen it before,it doesn't matter,I will give you a link:Here is the link:http://acm.原创 2015-02-10 21:17:21 · 1009 阅读 · 0 评论 -
poj2063 & hdu1963 Investment 又是DP啦,,经典完全背包问题
John never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John was the only inheritor. John did not need that much money for the mome原创 2015-02-10 17:32:22 · 1007 阅读 · 0 评论 -
hdu 2079 选课时间(题目已修改,注意读题) 多重背包
又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合。你来帮帮他吧。(xhd认为一样学分的课没区别) Input输入数据的第一行是一个数据T,表示有T组数据。每组数据的第一行是两个整数n(1 <= n <= 40),k(1 <= k <= 8)。接着有k行,每行有两个整数a(1 <= a <= 8),b(1 <= b <= 10),表示学分为a的课有b门。 Output对于每组输入数据,输出一个整数,表示学n个学分的组合数。原创 2015-02-11 22:38:06 · 1359 阅读 · 0 评论 -
hdu 2844 Coins 多重背包模板题 ,二进制优化。据说是楼教主的男人八题之一
Whuacmers 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 th原创 2015-02-11 14:48:47 · 1468 阅读 · 1 评论 -
hdu 1203 01背包变形。。。一道很诡异的水题。。
I NEED A OFFER!Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 26492 Accepted Submission(s): 10740Problem DescriptionSpeakless很早就原创 2017-03-02 00:36:13 · 701 阅读 · 0 评论