用户输出
1
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#100646 | #1086. jwp的幸运集合 | Accepted | 100 | 120 ms | 840 K | C++ 11 / 1.8 K | 2203714902 | 2023-08-09 9:56:46 |
#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp1;
map<long long, long long> mp2;
int main() {
long long n, x;
long long ans = 0;
vector<long long> a, b;
cin >> n;
for (long long i = 0; i < n; i++) {
cin >> x;
if (i < n / 2)
a.push_back(x);
else
b.push_back(x);
}
for (long long mask = 0; mask < 1 << a.size(); mask++) {
long long sum = 0;
long long tot = 0;
for (long long i = 0; i < a.size(); i++) {
if ((mask >> i) & 1) {
sum += a[i];
tot++;
}
}
if (tot % 2 == 0)
mp2[sum]++;
else
mp1[sum]++;
}
for (long long mask = 0; mask < 1 << b.size(); mask++) {
long long sum = 0;
long long tot = 0;
for (long long i = 0; i < b.size(); i++) {
if ((mask >> i) & 1) {
sum += b[i];
tot++;
}
}
if (tot % 2 == 0) {
map<long long, long long>::iterator it = mp2.find(-sum);
if (it != mp2.end()) {
// cout << it->first << " " << it->second << endl;
ans += it->second;
}
} else {
map<long long, long long>::iterator it = mp1.find(-sum);
if (it != mp1.end()) {
// cout << it->first << " " << it->second << endl;
ans += it->second;
}
}
}
/*map<int, int>::iterator it;
for (it = mp1.begin(); it != mp1.end(); it++)
cout << it->first << " " << it->second << endl;*/
cout << 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