摘要:
背包问题的第k大值 背包数组另开一维存储第k大值,每次优化时也优化这个维度 #include <iostream> #include <cstdlib> #include <cstring> #include <string> using namespace std; int mmax(int a, 阅读全文
posted @ 2020-02-09 20:11
Vetsama
阅读(75)
评论(0)
推荐(0)
摘要:
分组背包,如果分成01背包有可能会超限,使用二进制分组的方法 比如18=1+2+4+8+3 分解成二进制的大物品 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorit 阅读全文
posted @ 2020-02-09 19:58
Vetsama
阅读(82)
评论(0)
推荐(0)
摘要:
二维背包,加一个维度就好,这个时候就体现出来一维数组做背包多重要了,三维数组什么的,绝对要mle #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> usin 阅读全文
posted @ 2020-02-09 19:55
Vetsama
阅读(88)
评论(0)
推荐(0)
摘要:
01背包+完全背包+多重背包=? 大杂烩背包! 其实是叫混合背包 if else套对应的代码就行,多重背包转成01其实就是,但是我就不(滑稽) #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #i 阅读全文
posted @ 2020-02-09 19:52
Vetsama
阅读(125)
评论(0)
推荐(0)
摘要:
01背包,想了解背包的可以看看这个https://oi-wiki.org/dp/knapsack/ #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> usi 阅读全文
posted @ 2020-02-09 19:48
Vetsama
阅读(87)
评论(0)
推荐(0)
摘要:
分组,对每组进行01背包,x存组数,ans存每组有几个 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; int 阅读全文
posted @ 2020-02-09 19:42
Vetsama
阅读(131)
评论(0)
推荐(0)
摘要:
终于出现完全背包了,想的冷笑话可以用了 这个题 完完全全是完全背包啊!!! #include <iostream> #include <cstdio> using namespace std; int max(int a, int b){ return a > b ? a : b; } int ma 阅读全文
posted @ 2020-02-09 19:33
Vetsama
阅读(67)
评论(0)
推荐(0)
摘要:
这个题是以前做的,当时还不会一维数组做背包(丢人),普普通通的01背包 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdlib> #include <cstring> #include <string> using 阅读全文
posted @ 2020-02-09 19:30
Vetsama
阅读(72)
评论(0)
推荐(0)
摘要:
01背包,没啥说的,顺说点题目无关的吧,01背包从后往前推,完全背包从前往后推,要小心越界 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using n 阅读全文
posted @ 2020-02-09 19:28
Vetsama
阅读(125)
评论(0)
推荐(0)
摘要:
依旧是有一些疯狂的想法,把配件和主件存入一个容器里,然后在对主件背包时,对队伍里面的配件进行背包 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #inc 阅读全文
posted @ 2020-02-09 19:25
Vetsama
阅读(117)
评论(0)
推荐(0)
摘要:
看到这个题,有了一个大胆的想法,对方案数进行背包,对于一个pos【钱数】就是把每种能买的菜的pos【钱数-菜价】加起来,POS存放的是方案数 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #in 阅读全文
posted @ 2020-02-09 19:17
Vetsama
阅读(94)
评论(0)
推荐(0)
摘要:
题目一看就是标准的01背包,只需要在计算前把价格和重要度先计算了就好 #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace st 阅读全文
posted @ 2020-02-09 19:04
Vetsama
阅读(76)
评论(0)
推荐(0)

浙公网安备 33010602011771号