用户输出
1
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#80865 | #1086. jwp的幸运集合 | Accepted | 100 | 110 ms | 768 K | C++ 11 / 677 B | K-ON | 2022-08-03 11:30:26 |
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp[2];
int main() {
int n, ans = 0, len, s;
int a[40];
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
int ejz1, ejz2;
ejz1 = 1 << n / 2;
ejz2 = 1 << (n - n / 2);
for (int i = 0; i < ejz1; i++) {
s = 0;
len = 0;
for (int j = 0; j < n / 2; j++) {
if ((i >> j) & 1 != 0) {
s = s + a[j];
len++;
}
}
mp[len % 2][s]++;
}
for (int i = 0; i < ejz2; i++) {
s = 0;
len = 0;
for (int j = 0; j < n - n / 2; j++) {
if ((i >> j) & 1 != 0) {
s = s + a[n / 2 + j];
len++;
}
}
ans += mp[len % 2][-s];
}
printf("%d", ans - 1);
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