![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
背包问题
deebcjrb
这个作者很懒,什么都没留下…
展开
-
【每日一题】8月4日题目精讲—购物 (背包问题)
https://ac.nowcoder.com/acm/problem/14526首先我们每天肯定都是按照价格从低到高买糖果,所以决策只需要关注当前天买了多少个。f[i][j]代表前i天已经买了j颗糖果的最小花费,枚举第i天买了多少糖果。f[i][j] = min(f[i-1][k] + sum[i][i-k] + (j-k)*(j-k)); (k从i-m到i-1枚举)#include<iostream>#include<string>#include<mat原创 2020-08-19 22:30:56 · 122 阅读 · 0 评论 -
货币系统 (完全背包)
https://ac.nowcoder.com/acm/problem/21228首先我们要想到,最后的最小的货币系统应该是原货币系统的一个子集,原因也很简单——如果a能够用其他一个或若干个面值表示那么它显然不必要,而如果你去引入一个原来不存在的数那么要么是多于的(能被原来货币系统里面的一个或多个数表达)要么就会引入新的东西。所以现在我们要做到就是在刚刚的集合里面求所有必要的无法被替代的货币数量。显然,最小的数肯定要留下,因为其他数字肯定表示不了它。然后第二大的数,如果是最小的数的倍数就不需要,不原创 2020-05-30 17:32:01 · 873 阅读 · 0 评论 -
Robberies (01背包问题)
原题目:RobberiesTime Limit: 1000msMemory Limit: 32768KB This problem will be judged on HDU. Original ID: 295564-bit integer IO format: %I64d Java class name: MainPrev Submit Status Statistic...原创 2019-07-25 22:07:50 · 82 阅读 · 0 评论 -
Big Event in HDU (多重背包问题)
原题目:Nowadays, 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 College in 20...原创 2019-07-25 19:37:12 · 138 阅读 · 0 评论 -
饭卡 HDU(背包问题)
原题目:电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input多组数据。对于每组数据:第一行为正...原创 2019-07-25 17:41:59 · 101 阅读 · 0 评论 -
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 HDU-2191(多重背包模板)
原题目:急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。月有阴晴圆缺,人有旦夕祸福,未来对于我们而言是一个未知数...原创 2019-07-25 16:06:27 · 89 阅读 · 0 评论 -
Bone Collector (01背包问题模板)
原题目: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 coll...原创 2019-07-25 15:05:01 · 100 阅读 · 0 评论 -
(kuangbin带你飞--基础DP)Piggy-Bank (完全背包)
原题目: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 ...转载 2019-08-05 14:07:12 · 140 阅读 · 0 评论 -
Just another Robbery (概率+01背包)
原题目:As Harry Potter series is over, Harry has no job. Since he wants to make quick money, (he wants everything quick!) so he decided to rob banks. He wants to make a calculated risk, and grab as muc...原创 2019-08-16 09:39:08 · 107 阅读 · 0 评论