摘要: 1 /**\ 2 https://codeforces.com/problemset/problem/1609/C 3 一堆数相乘是质数,其中只有一个是质数, 4 统计左边的1的个数,右边1的个数,累加即可 5 \**/ 6 #include <bits/stdc++.h> 7 using name 阅读全文
posted @ 2022-03-09 17:54 std&ice 阅读(60) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 1009; int n; int a[N], f[N]; signed main() { ios::sync_with_stdio(false); cin >> n; for(in 阅读全文
posted @ 2022-03-09 10:58 std&ice 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 每组物品有若干个,同一组内的物品最多只能选一个 3 \**/ 4 #include <bits/stdc++.h> 5 using namespace std; 6 const int N = 1e3 + 9; 7 int n, m, v[N][N], w[N][N], s[N]; 阅读全文
posted @ 2022-03-09 10:54 std&ice 阅读(48) 评论(0) 推荐(0) 编辑
摘要: /**\ n种物品,第i种物品重量wi,价值vi,物品ci个,背包容量为m 例如某物品a,价值v,重量w,数量c个。 假设c=13,有13这样子的物品,我们使用二进制拆分,将13拆分为几个整数的和 拆成1、2、4、6,这样子1~13中任何的数都能由任意两个数组成。 for (int i = 1; i 阅读全文
posted @ 2022-03-09 10:48 std&ice 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #define int long long 3 using namespace std; 4 const int mx = 1e7 + 9; 5 int n, m, dp[mx], w[mx], v[mx]; 6 signed main() { 7 c 阅读全文
posted @ 2022-03-09 10:34 std&ice 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 普通版本 /**\ f[i][j] 表示 前i件物品容量为j时最大价值 \**/ #include <bits/stdc++.h> using namespace std; const int N = 1010; int n, m, v[N], w[N], f[N][N]; signed main( 阅读全文
posted @ 2022-03-09 10:29 std&ice 阅读(54) 评论(0) 推荐(0) 编辑