??? 例题代码
- ```cpp
+ ```cpp
#include <iostream>
const int maxn = 13010;
int n, v, w[maxn], v[maxn], f[maxn];
std::cout << f[W];
return 0;
}
- ```
+ ```
## 完全背包
??? 例题代码
- ```cpp
+ ```cpp
#include <iostream>
const int maxn = 13010;
int n, v, w[maxn], v[maxn], f[maxn];
std::cout << f[W];
return 0;
}
- ```
+ ```
## 多重背包
??? 二进制分组代码
- ```cpp
+ ```cpp
index = 0;
for(int i = 1; i <= m; i++) {
int c = 1, p, h, k;
list[++index].w = p * k;
list[index].v = h * k;
}
- ```
+ ```
??? note "[「Luogu P1776」宝物筛选\_NOI 导刊 2010 提高(02)](https://www.luogu.org/problemnew/show/P1776)"
题意概要:有 $n$ 种物品和一个容量为 $W$ 的背包,每种物品有重量 $w_{i}$ ,价值 $v_{i}$ 和数量 $m_v{i}$ 两种属性,要求选若干个物品放入背包使背包中物品的总价值最大且背包中物品的总重量不超过背包的容量。有一点需要注意的是本题数据范围较大,情况较多。