
数据结构之背包
文章平均质量分 82
曉_寧
这个作者很懒,什么都没留下…
展开
-
HDU 1114 Piggy-Bank 完全背包的变形
DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea b原创 2014-08-13 20:18:47 · 663 阅读 · 0 评论 -
HDU 3033 I love sneakers! 分组背包变形
DescriptionAfter months of hard working, Iserlohn finally wins awesome amount of scholarship. As a great zealot of sneakers, he decides to spend all his money on them in a sneaker store. The原创 2015-01-30 09:41:43 · 1789 阅读 · 0 评论 -
poj 3211 Washing Clothes 01背包
DescriptionDearboy was so busy recently that now he has piles of clothes to wash. Luckily, he has a beautiful and hard-working girlfriend to help him. The clothes are in varieties of colors but原创 2015-01-31 11:33:23 · 534 阅读 · 0 评论 -
poj 1837 Balance 二维费用背包
题意:给你c(2思路:(这是我木有想到的)将g个挂钩挂上的极限值:15*25*20==7500那么在有负数的情况下是-7500~~7500 以0为平衡点......那可以将平衡点往右移7500个单位,范围就是0~~15000......这样就好处理多了其实我觉得以后的题目中不仅仅天平问题可以这样处理,在有负数的以及要装入数组处理的题目中,我们都可以尝试着平移简化原创 2015-01-30 20:36:49 · 1528 阅读 · 0 评论 -
HDU 1864 最大报销额 背包(处理浮点数小技巧)
Description现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最大报销额。 Input测试输入包含若干测试用例。每个测试用例的第1行包含两个正数原创 2014-08-13 20:33:01 · 523 阅读 · 0 评论 -
poj 1976 A Mini Locomotive 二维背包
问题描述: 一辆火车用一个车头来拉动装着乘客的车厢。如果这个车头坏了,就没有其它方法可以用来拉动火车了, 因此,铁道官方决定为每个车站配备三个迷你型的小车头。一个迷你车头只能拉动那些乘客比较小的车厢 如果一个火车头坏了,三个迷你车厢不能拉动所有装载乘客的车厢,故铁道官方做了如下决定: 1.将车厢的最大乘客数设置为一个迷你车头可拉动的最大值。对于每个迷你车厢,该数字原创 2015-02-02 19:50:20 · 638 阅读 · 0 评论 -
hdu 3449 Consumer 有依赖的01背包
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 stuf原创 2015-02-02 11:20:50 · 504 阅读 · 0 评论 -
hdu 2159 FATE 二维背包
Description最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他原创 2015-02-02 16:48:21 · 531 阅读 · 0 评论 -
poj 1252 Euro Efficiency 完全背包,可以找零
题目大意:给6种不同面额硬币,求组成[1,100]中数的平均需要硬币与最多需要硬币数,可以通过减法获得,比如有1、4两种硬币,凑成3可以用4-1两个硬币完成,而不是1+1+1三个硬币。乍一看,很水的题,DP做得话要注意两点:一:题目不仅仅有+的操作,也有哦-的操作,所以需要正向和反向各dp一遍才行。。二:题目dp不能只开到100.。而是要开大点,到2000足以。。因为我们假设。原创 2015-02-04 10:06:42 · 548 阅读 · 0 评论 -
poj 2063 Investment 背包
水题,唯一要注意的就是你要进行n年,每年的初始化金币不一样。算一每年要算一遍DescriptionJohn never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lo原创 2015-02-04 10:12:50 · 503 阅读 · 0 评论 -
hdu 2955 Robberies 背包
题意:求在给定的被捉概率范围内列出每个银行的钱和被捉概率 求出最大抢到的钱数.超出给定的被捉率她妈妈就不会给他去冒险!DescriptionThe aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught i原创 2015-02-04 10:21:03 · 573 阅读 · 0 评论 -
HDU 2191 悼念512汶川大地震遇难同胞――珍惜现在,感恩生活 多重背包
背包水题Problem Description急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知原创 2015-02-04 10:15:00 · 505 阅读 · 0 评论 -
poj 3628 Bookshelf 2 背包
水题,直接没看题意DescriptionFarmer John recently bought another bookshelf for the cow library, but the shelf is getting filled up quite quickly, and now the only available space is at the原创 2015-02-04 10:10:15 · 633 阅读 · 0 评论 -
poj 3624 Charm Bracelet 背包
水题不解释DescriptionBessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) av原创 2015-02-04 10:08:35 · 473 阅读 · 0 评论 -
hdu 3496 Watch The Movie 二维费用背包
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 wants her原创 2015-01-29 16:28:55 · 734 阅读 · 0 评论 -
poj2392 Space Elevator 多重背包转换为完全背包
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原创 2015-01-28 23:38:40 · 884 阅读 · 0 评论 -
Fighting 背包
题目描述怒海争锋是一个新游戏,类似于星际争霸。在这个游戏中,敌人建造防御塔,血量为L。玩家有一个军事工厂,可以生产N种战斗舰艇。第i个战舰的生产时间为ti,这战舰每秒钟可以让塔损失血量为li。如果塔的寿命低于或等于0,玩家获胜。注意,在每一秒内,军事工厂只能选择一种战斗船生产或什么也不做。选择后的战斗舰艇生产时不可以同时生产。生产完一个再生产下一个。 你的任务是找出玩家赢得比赛的最原创 2014-02-20 20:48:37 · 740 阅读 · 0 评论 -
HDU 2602 Bone Collector
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 …The bone collector原创 2014-02-12 19:59:53 · 687 阅读 · 0 评论 -
小P的故事——神奇的换零钱 背包
题目描述已知A国经济很落后,他们只有1、2、3元三种面值的硬币,有一天小P要去A国旅行,想换一些零钱,小P很想知道将钱N兑换成硬币有很多种兑法,但是可惜的是他的数学竟然是体育老师教的,所以他不会啊、、、他只好求助于你,你可以帮他解决吗?提示:输入数据大于32000组。输入 每行只有一个正整数N,N小于32768。输出 对应每个输入,输出兑换方法数原创 2014-02-15 01:01:22 · 810 阅读 · 0 评论 -
poj 3624 Charm Bracelet 背包
DescriptionBessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each原创 2014-02-11 21:15:57 · 717 阅读 · 0 评论 -
背包初步了解
0/1 背包问题动态规划详解及C代码动态规划是用空间换时间的一种方法的抽象。其关键是发现子问题和记录其结果。然后利用这些结果减轻运算量。比如01背包问题。/* 一个旅行者有一个最多能用M公斤的背包,现在有N件物品,它们的重量分别是W1,W2,...,Wn,它们的价值分别为P1,P2,...,Pn.若每种物品只有一件求旅行者能获原创 2014-02-12 09:13:44 · 605 阅读 · 0 评论 -
小P的故事——神奇的饭卡
题目描述 话说sdut大学驰名已久,所以吸引了无数2014级的小学弟、小学妹们前来参加艺考,为了配合学校高大形象,校餐厅特提议推出一款高端大气上档次的神奇饭卡,供学弟、学妹们使用。 这个饭卡十分的神奇,如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。可惜参加艺考的同学们不原创 2014-02-12 14:55:43 · 1103 阅读 · 0 评论 -
小P的故事——神奇的Dota
题目描述小P非常喜欢玩dota,不分昼夜的玩,结果他连做梦也都是里面的画面,一天晚上小P刚躺下就做了一个神奇的梦。。。不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!"地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水原创 2014-02-12 17:31:10 · 701 阅读 · 0 评论 -
hdu 1171 Big Event in HDU 多重背包
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 Computer College and Software Coll原创 2015-01-27 16:01:28 · 463 阅读 · 0 评论 -
hdu 1059 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原创 2015-01-26 10:39:26 · 623 阅读 · 0 评论 -
poj 1276 Cash Machine 多重背包
DescriptionA Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct bill denomin原创 2015-01-29 09:11:11 · 497 阅读 · 0 评论 -
hdu 3535 AreYouBusy 混合背包
个人感觉思路一点不好想,看了网上的总算是懂了,也自己敲了敲,懂思路就很简单了题意:给你n种工作,给你T的时间去做它们。给你m和s,说明这种工作有m件事可以做,它们是s类的工作(s=0,1,2,s=0说明这m件事中最少得做一件,s=1说明这m件事中最多只能做一件,s=2说明这m件事你可以做也可以不做)。再给你ci和gi代表你做这件事要用ci的时间,能获得gi的快乐值。求在T的时间内你能获得的原创 2015-01-29 11:38:25 · 476 阅读 · 0 评论 -
hdu 2844 Coins 多重背包+二进制优化
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原创 2015-01-27 20:01:14 · 573 阅读 · 0 评论 -
hdu 1712 ACboy needs your help 分组背包
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 arrange原创 2015-01-30 09:35:10 · 591 阅读 · 0 评论 -
SDUT 2776 小P的故事——神奇的分组 二分
题目描述众所周知小P是一个十分有爱心的同学,所以他热衷于各种志愿活动,一天小P参加一个志愿活动,由于小P是某名校大学生,所以分组的事情大家想让小P来做,可是他的高数只考了4分,显然不能完成这项任务,所以他就偷偷的让我来找你帮他解决问题,我想聪明非凡你一定可以解决!已知有n位志愿者,需要将他们分为若干个小组,小组的数量不限,但是要求每个小组的人数必须为素数,请问我们有几种分组的方法呢?原创 2014-08-14 00:54:46 · 677 阅读 · 0 评论