随笔分类 - 动态规划之背包问题
摘要:#include <iostream> #include <algorithm> #include <cstring> using namespace std; const int N = 110; int n, m; int s[N], f[N]; int v[N][N], w[N][N]; in
阅读全文
摘要:题目链接 AcWing 5.多重背包问题II 二进制优化多重背包 二进制优化原理(不难证明) 对于一个整数S,不妨设 S = \((1101011)_{2}\) 为 7位2进制整数, 我们可以由{\({2^0,2^1,2^2,2^3,2^4,2^5,2^6,2^7}\)}(集合中的元素要么选,要么不
阅读全文
摘要:题目链接AcWing 4.多重背包问题 朴素版 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 110; int n, m; int f[N][N]; //f
阅读全文
摘要:题目链接 AcWing 3. 完全背包问题 朴素法 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 1010; int n, m; int v, w; int
阅读全文
摘要:题目链接 Acwing 2. 01背包 朴素版01背包 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 1010; int n, m; int v, w; i
阅读全文
浙公网安备 33010602011771号