
ACM--动态规划
文章平均质量分 71
努力过
喜欢coding
展开
-
HDU 5115 M - Dire Wolf 【区间dp】
Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not all, Dire Wolves appear to originate from Draenor. Dire wolves look like normal wolves, but thes...原创 2018-05-11 00:18:47 · 170 阅读 · 0 评论 -
第七届河南省程序设计大赛 H : Rectangles
题目描述 Given N (4 <= N <= 100) rectangles and the lengths of their sides ( integers in the range 1..1,000), write a program that finds the maximum K for which there is a sequence of K of the give...原创 2018-04-28 13:25:16 · 136 阅读 · 0 评论 -
HZAU 1199 Little Red Riding Hood【dp】
Once upon a time, there was a little girl. Her name was Little Red Riding Hood. One day, her grandma was ill. Little Red Riding Hood went to visit her. On the way, she met a big wolf. “That's a goo...原创 2018-04-17 07:50:53 · 261 阅读 · 0 评论 -
hihocoder #1044 Q - 状态压缩·一 【第四周练习】【the fourth day】
描述 小Hi和小Ho在兑换到了喜欢的奖品之后,便继续起了他们的美国之行,思来想去,他们决定乘坐火车前往下一座城市——那座城市即将举行美食节! 但是不幸的是,小Hi和小Ho并没有能够买到很好的火车票——他们只能够乘坐最为破旧的火车进行他们的旅程。 不仅如此,因为美食节的吸引,许多人纷纷踏上了和小Hi小Ho一样的旅程,于是有相当多的人遭遇到了和小Hi小Ho一样的情况——这导致这辆车上的人非常非常...原创 2018-02-11 18:48:35 · 239 阅读 · 0 评论 -
poj 3254 Corn Fields【状态压缩dp】【入门第一题~~】
Corn FieldsTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 17938 Accepted: 9447DescriptionFarmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12)...原创 2018-02-10 15:40:27 · 290 阅读 · 0 评论 -
poj1976 A Mini Locomotive 【二维01背包】
A train has a locomotive that pulls the train with its many passenger coaches. If the locomotive breaks down, there is no way to pull the train. Therefore, the office of railroads decided to distribut原创 2018-01-29 11:06:02 · 246 阅读 · 0 评论 -
hdu 1160 FatMouse's Speed 【lis+记录路径】
FatMouse believes that the fatter a mouse is, the faster it runs. To disprove this, you want to take the data on a collection of mice and put as large a subset of this data as possible into a sequence原创 2018-01-05 11:32:35 · 283 阅读 · 0 评论 -
hdu 1176 免费馅饼 【dp】
都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝原创 2018-01-03 13:17:52 · 251 阅读 · 0 评论 -
hdu 1950 【最长上升子序列 复杂度nlogn】
Bridging signalsTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3080 Accepted Submission(s): 1945Problem Description'Oh no, t原创 2017-10-10 16:53:30 · 256 阅读 · 0 评论 -
hdu 1864 最大报销额【01背包变形~】(实数转整型)
最大报销额Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 27158 Accepted Submission(s): 8335Problem Description现有一笔经费可以报销一定额度的发票。允原创 2017-09-19 16:32:24 · 412 阅读 · 0 评论 -
hdu2571命运 【dp】
命运Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20491 Accepted Submission(s): 7133Problem Description穿过幽谷意味着离大魔王lemon已经无限接近原创 2017-09-19 15:31:17 · 304 阅读 · 0 评论 -
hdu 5366 The mook jong 【dp】
The mook jongTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1065 Accepted Submission(s): 702Problem Description. The idea behind is simple原创 2017-08-28 09:33:20 · 229 阅读 · 0 评论 -
【背包专题】H - 钱币兑换问题 hdu1284【完全背包】
在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。Input每行只有一个正整数N,N小于32768。Output对应每个输入,输出兑换方法数。Sample Input293412553Sample Output71883113137761思路:完全背包来解决这道题。先递推出只兑换1分硬币时的兑换方法有多少种,再递推出加原创 2017-08-27 13:03:41 · 349 阅读 · 0 评论 -
【背包专题】C - The trouble of Xiaoqian hdu3591【混合背包:多重背包+完全背包】
In 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原创 2017-08-27 11:11:57 · 247 阅读 · 0 评论 -
【背包专题】G - Dividing hdu 1059【多重背包】
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 v原创 2017-08-26 15:21:19 · 255 阅读 · 0 评论 -
【背包专题】I - 湫湫系列故事——减肥记I hdu4508【完全背包】
对于吃货来说,过年最幸福的事就是吃了,没有之一! 但是对于女生来说,卡路里(热量)是天敌啊! 资深美女湫湫深谙“胖来如山倒,胖去如抽丝”的道理,所以她希望你能帮忙制定一个食谱,能使她吃得开心的同时,不会制造太多的天敌。 当然,为了方便你制作食谱,湫湫给了你每日食物清单,上面描述了当天她想吃的每种食物能带给她的幸福程度,以及会增加的卡路里量。Input 输入包含原创 2017-08-26 14:30:13 · 236 阅读 · 0 评论 -
【背包专题】F - Ahui Writes Word hdu3732【01背包+二进制优化】
We all know that English is very important, so Ahui strive for this in order to learn more English words. To know that word has its value and complexity of writing (the length of each word does not ex原创 2017-08-26 11:49:32 · 213 阅读 · 0 评论 -
【背包专题】 D - Coins hdu2844【多重背包】
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 wante原创 2017-08-25 20:59:47 · 360 阅读 · 0 评论 -
【背包专题】D - Coins hdu 2844 【01背包+二进制优化】
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 wante原创 2017-08-25 16:57:05 · 421 阅读 · 0 评论 -
【背包专题】B - FATE hdu2159【二维完全背包】
最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他能升掉这最后一级吗?I原创 2017-08-25 09:11:29 · 184 阅读 · 0 评论 -
【背包专题】A - Bone Collector II hdu2639 【01背包的第k个最优解】
The 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原创 2017-08-24 11:37:56 · 240 阅读 · 0 评论 -
【背包专题】E - 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 hdu2191【多重背包】
急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。 请问:你用有限的资金最多能采购多少公斤粮食呢? 后记: 人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。 月有阴晴圆缺,人有旦夕祸福,未来对于我们而言原创 2017-08-23 20:25:58 · 218 阅读 · 0 评论 -
【多校连萌2】D题 ykc想吃好吃的【补题】【最大子段和变形题】
题目描述一天,ykc在学校闲的无聊,于是决定上街买点吃的,ykc很懒,本来就不是很像逛街,于是找来了czl帮他买,这里应该有滑稽,而czl也不愿为ykc买东西吃,但是ykc很强势,非让他去买,呢没办法了,然而czl还有很多事要做,没呢么多时间帮ykc,而这条小吃街又很长,有n家店,n有50000这么大,并且这n家店的商品价值有所不同(要知道,商品的价值可能为负,哈哈,很神奇吧,但是czl肯原创 2017-08-05 09:49:00 · 342 阅读 · 0 评论 -
【多校连萌2】1281: 邪能炸弹【补题】
题目描述正在入侵艾泽拉斯的古尔丹偶然间得到了一颗邪能炸弹,经过研究,他发现这是一颗威力极其巨大且难以控制的炸弹。但是精通邪能的古尔丹突然有了一个大胆的想法,他对炸弹进行了一些小小的改造。这使得炸弹需要n天的充能才能爆炸,在这n天中,每天炸弹的邪能值都会产生波动,波动值为xi,古尔丹唯一能控制的是使邪能值增加xi或减少xi,如果邪能值小于0或大于MAX,那么炸弹将会损坏并失效。机智如古尔丹当原创 2017-08-05 06:14:59 · 342 阅读 · 0 评论 -
【多校连萌2】A 简单的背包问题【补题】
1279: 简单的背包问题时间限制: 1 秒 内存限制: 32 MB提交: 363 解决: 21提交 状态 题目描述相信大家都学过背包问题了吧,那么现在我就考大家一个问题。有n个物品,每个物品有它的重量w,价值v,现在有一个容量为W的背包,问你在不超过背包容量的情况下,能装下的物品的最大价值是多少。T 1 1 1 对于每个i=2,3,…,N,原创 2017-08-04 22:57:25 · 256 阅读 · 0 评论 -
hdu 2639 【01背包的第k个最优解】
Bone Collector IIProblem 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原创 2017-07-28 13:13:27 · 523 阅读 · 0 评论 -
poj 1014 Dividing 【多重背包】
DividingDescriptionMarsha 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 a原创 2017-07-27 15:44:42 · 406 阅读 · 0 评论 -
hdu1231 最大连续子序列
最大连续子序列Problem Description给定K个整数的序列{ N1, N2, ..., NK },其任意连续子序列可表示为{ Ni, Ni+1, ..., Nj },其中 1 例如给定序列{ -2, 11, -4, 13, -5, -2 },其最大连续子序列为{ 11, -4, 13 },最大和 为20。 在今年的数据结构考卷中,要求编写程序原创 2017-07-27 08:20:50 · 208 阅读 · 0 评论 -
【dp专题1】hdu1087最大上升子段和 E - Super Jumping! Jumping! Jumping!
Super Jumping! Jumping! Jumping!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 lit原创 2017-07-26 15:42:39 · 456 阅读 · 1 评论 -
【dp专题1】F - Common Subsequence 【最长公共子序列模板LCS】hdu1159
A 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原创 2017-07-25 18:34:23 · 248 阅读 · 0 评论 -
【dp专题1】B - I NEED A OFFER! 【01背包】 hdu1203
B - I NEED A OFFER! 01背包简单的应用,求至少一份的最大概率,要注意数组的初始化和状态转移方程。数组初始化为1表示得不到offer的概率为1状态转移方程:f[j] = min( f[j] , f[j-w[i]]*(1-v[i]) )表示每次求得不到offer的最小概率。1 - 得不到offer的最小概率 = 得到至少一份offer的最大概率原创 2017-07-25 14:58:26 · 240 阅读 · 0 评论 -
hdu 1171 Big Event in HDU 01背包
Big Event in HDUProblem 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 Co原创 2017-07-24 18:04:12 · 194 阅读 · 0 评论 -
HDU 2048 数塔 简单DP
数塔Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗? Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例原创 2017-07-24 13:43:41 · 251 阅读 · 0 评论 -
51nod 1006 最长公共子序列Lcs【模板】
给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。 比如两个串为:abcicba abdkscabab是两个串的子序列,abc也是,abca也是,其中abca是这两个字符串最长的子序列。 Input 第1行:字符串A 第2行:字符串B(A,B的长度 <= 1000) Output输出最长的子序列,如果有多个,随意输出1个。 Input示例 abcicba ab原创 2017-06-29 18:59:54 · 321 阅读 · 0 评论 -
HDU2602 01背包入门 Bone Collector【01背包模板题】
Problem Description Many 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 …原创 2017-05-05 16:32:39 · 1022 阅读 · 0 评论 -
HDU2546饭卡 01背包入门
** Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input 多原创 2017-05-05 07:31:49 · 382 阅读 · 0 评论 -
HAUTOJ 1266: 最大子段和 河工大校赛DP
**1266: 最大子段和题目描述一个大小为n的数组a1到an(−10^4≤ai≤10^4)。请你找出一个连续子段,使子段长度为奇数,且子段和最大。输入第一行为T(1≤T≤5),代表数据组数。 之后每组数据,第一行为n(1≤n≤10^5),代表数组长度。 之后一行n个数,代表a1到an。输出每组数据输出一行,表示满足要求的子段和最大值 样例输入1 4 1 2 3 4 样例输出9**题目很原创 2017-05-03 19:13:10 · 483 阅读 · 0 评论 -
hdu杭电1003 dp 连续子序列最大值
Problem Description Given 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 =原创 2017-04-26 07:27:54 · 355 阅读 · 0 评论