用户输出
1
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#81160 | #1086. jwp的幸运集合 | Accepted | 100 | 115 ms | 836 K | C++ / 754 B | BMforever | 2022-08-18 17:17:16 |
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp[2];
int main() {
int n, a[40], arr[2][200000], tot[2], ans = 0;
memset(tot, 0, sizeof(tot));
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
int left = 1 << (n / 2), right = 1 << (n - n / 2);
for (int i = 1; i < left; i++) {
int sum = 0, len = 0;
for (int j = 0; j < n / 2; j++) {
if ((1 << j) & i) {
sum += a[j];
len++;
}
}
mp[len & 1][sum]++;
if (sum == 0 && (len & 1) == 0)
ans++;
}
for (int i = 0; i < 2; i++) sort(arr[i], arr[i] + tot[i]);
for (int i = 1; i < right; i++) {
int sum = 0, len = 0;
for (int j = 0; j < n - n / 2; j++) {
if ((1 << j) & i) {
sum += a[j + n / 2];
len++;
}
}
if (sum == 0 && (len & 1) == 0)
ans++;
ans += mp[len & 1][-sum];
}
printf("%d", ans);
return 0;
}
31
749 349 69 -880 282 -926 -831 225 988 552 -193 634 369 476 204 487 387 -803 -370 -975 -17 -485 3
<40 bytes omitted>
用户输出
260459
系统信息
Exited with return code 0
31
362 -14 -181 -465 -400 -232 26 963 70 728 -728 -222 -510 854 139 386 555 994 103 279 213 76 953
<36 bytes omitted>
用户输出
81861
系统信息
Exited with return code 0
用户输出
16383
系统信息
Exited with return code 0