版本比较
10.17二进制枚举总结
正文
增加 17 行删除 17 行
14 行未改动1516171819192021222357 行未改动818283848586858687888889909192939293949596969798999910010110110210310410557 行未改动16316416516616716716816917017117217217317417517613 行未改动19019119219319419419519619719719819920020112 行未改动2142152162172182182192202212223 行未改动2262272282292302302312322332344 行未改动23924024124224324324424524624711 行未改动25926026126226326326426526626714 行未改动你希望计划成功率最大。因此,你需要选出合适的人士,来参与到你的宏图伟业中。
## 输入格式
第一行,两个正整数 $n, k$。分别表示供你挑选的人的数量,以及能力的种类数。 第一行,两个正整数 $n, k$。分别表示供你挑选的人的数量,以及能力的种类数。接下来 $n$ 行,每行表示每个人拥有的能力。这一行首先有一个整数 $c$,表示该人士拥有多少种能力;接下来是 $c$ 个 $[1, k]$ 之间的正整数,表示该人士拥有哪些能力。
## 输出格式
57 行未改动### 输入 #4
```21 600 0 003 60 27 480 01 482 52 142 4 310 0 002 28 432 6 310 01 73 45 6 480 01 510 02 28 202 37 511 853 59 39 29 23 53 27 13 16 44 34 38 24 9 32 58 54 31 1 7 45 3 30 36 17 48 42 22 18 21 6 11 25 33 37 52 10 60 49 57 2 28 8 14 5 47 4 41 35 43 50 46 26 1257 行未改动using namespace std;int n, k;long long a[50], s, u, ans;int main() { cin >> n >> k; cin >> n >> k; for (int i = 1; i <= n; i++) { long long c, x; cin >> c; while(c--) cin >> x, a[i] |= long(pow(2, k - x)); } long long len = 1 << n; long long len = 1 << n; for (int i = 0; i < len; i++) { long long sum = 0; for (int j = 0; j < n; j++) if (i >> j & 1) sum ^= a[j + 1];13 行未改动int h[1000007];int main() { cin >> n >> b; for (int i = 1; i <= n; i++) cin >> h[i]; int len = 1 << n; int len = 1 << n; for (int i = 0; i < len; i++) { int s = 0; for (int j = 0; j < n; j++) for (int j = 0; j < n; j++) if (i >> j & 1) s += h[j + 1]; if (s >= b) ans = min(ans, s - b); } cout << ans << endl;12 行未改动 cin >> n >> m >> k >> r; for (int i = 1; i <= n; i++) cin >> t[i]; for (int i = 1; i <= m; i++) cin >> tt[i]; for (int i = 1; i <= m; i++) cin >> s[i]; int len = 1 << m; int len = 1 << m; for (int i = 0; i < len; i++) { int st = 0, sf = 0; for (int j = 0; j < m; j++) if (i >> j & 1) {st += tt[j + 1], sf += s[j + 1];}3 行未改动 int rt = r - ans; sort(tt + 1, tt + n + 1); int count = 0; for (int i = 1; i <= n; i++) { if (rt >= t[i]) {count++; rt -= t[i];} if (rt >= t[i]) {count++; rt -= t[i];} else break; } cout << count << endl; return 0;4 行未改动```cpp#include <bits/stdc++.h>#define ll long longusing namespace std;int n, ans = 1e9; int n, ans = 1e9;int a[1000007], b[1000007];int read() { int r = 0, f = 1; char c = getchar(); while ((c < '0' || c > '9') && (c ^ '-')) c = getchar();11 行未改动 if (i >> j & 1) x *= a[j + 1], y += b[j + 1]; if (x == 1 && y == 0) continue; ans = min(ans, abs(x - y)); } cout << ans; cout << ans; return 0;}
```