用户输出
1
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#22769 | #1086. jwp的幸运集合 | Accepted | 100 | 67 ms | 1048 K | C++ 17 / 743 B | Leohh | 2020-02-14 17:51:46 |
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <map>
#define MAX_N 40
#define int long long
using namespace std;
int n, ans = 0;
int a[MAX_N];
map<int, int> mp[2];
void dfs1(int x, int s, int c) {
if (x > (n >> 1)) {
mp[c & 1][s]++;
return;
}
dfs1(x + 1, s, c);
dfs1(x + 1, s + a[x], c + 1);
}
void dfs2(int x, int s, int c) {
if (x > n) {
ans += mp[c & 1][-s];
return;
}
dfs2(x + 1, s, c);
dfs2(x + 1, s + a[x], c + 1);
}
signed main() {
scanf("%lld", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld", a + i);
}
dfs1(1, 0, 0);
dfs2((n >> 1) + 1, 0, 0);
printf("%lld\n", ans - 1);
}
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