![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
背包
Are_you_ready
这个作者很懒,什么都没留下…
展开
-
多重背包问题(二进制优化)
题目:https://www.acwing.com/problem/content/5/ 优化:将每一个商品的数量用二进制的方法分割一下,如:这件商品本来有200个,我就可以分割成1,2,4,8,16,32,64,73,这样这几个数每一个数最多只能用一次,那么这几个数任意组合就可以组成小于等于200的任何数,利用这个思想,将每一件商品的数量都进行这样的划分重新组合成新的商品,然后跑一边01背包就行。 #include <bits/stdc++.h> using namespace std; ty原创 2021-01-29 20:48:09 · 163 阅读 · 0 评论 -
D - Pick The Sticks HDU - 5543(特殊的01背包,dp,放金条超出背包空间)
D - Pick The Sticks HDU - 5543 The story happened long long ago. One day, Cao Cao made a special order called “Chicken Rib” to his army. No one got his point and all became very panic. However, Cao Cao himself felt very proud of his interesting idea and en原创 2020-08-13 21:29:45 · 246 阅读 · 0 评论 -
C - Canonical Coin Systems Kattis - canonical(硬币组成钱--贪心+完全背包的对比)
C - Canonical Coin Systems Kattis - canonical A coin system S is a finite (nonempty) set of distinct positive integers corresponding to coin values, also called denominations, in a real or imagined monetary system. For example, the coin system in common us原创 2020-08-11 11:34:22 · 265 阅读 · 0 评论 -
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 HDU - 2191(特殊01背包)
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 HDU - 2191 急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。 请问:你用有限的资金最多能采购多少公斤粮食呢? 后记: 人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。 月有阴晴圆缺,人有旦夕祸福,未来对于我们而言是一个未知数。那么,我们要做的就应该是珍惜现在,感恩生活——原创 2020-05-09 16:56:16 · 261 阅读 · 0 评论 -
Coins HDU - 2844(多重背包)
Coins HDU - 2844 (多重背包) 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 c原创 2020-05-09 15:20:12 · 158 阅读 · 0 评论 -
Piggy-Bank HDU - 1114 (完全背包)
Piggy-Bank HDU - 1114 Before 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 behind is simple. Whenever some ACM member has any原创 2020-05-08 22:07:21 · 113 阅读 · 0 评论 -
饭卡 HDU - 2546
饭卡 HDU - 2546 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 Input 多组数据。对于每组数据:...原创 2020-05-06 18:18:19 · 217 阅读 · 0 评论