用户输出
34
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#22770 | #1121. jwp的幸运集合(弱化版) | Accepted | 100 | 20 ms | 356 K | C++ 17 / 743 B | Leohh | 2020-02-14 17:52:36 |
#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);
}
用户输出
34
系统信息
Exited with return code 0
用户输出
69
系统信息
Exited with return code 0
20
50000000 -50000000 50000000 -50000000 50000000 -50000000 50000000 -50000000 50000000 -50000000 50
<93 bytes omitted>
用户输出
184755
系统信息
Exited with return code 0
20
50000000 50000000 50000000 50000000 50000000 50000000 50000000 50000000 50000000 50000000 5000000
<82 bytes omitted>
用户输出
0
系统信息
Exited with return code 0
用户输出
255
系统信息
Exited with return code 0