#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cerr << #x << " " << x << endl
#define int long long
#define st first
#define nd second
using namespace std;
const int N(3e5 + 13);
const int MAX(LLONG_MAX);
const int MOD(1e9+7);
int n, cnt_0;
int arr[N], sumpref[N];
bool flag;
string s;
int32_t main() {
boost;
cin >> n;
for (int i = 1; i <= n;i++) {
cin >> arr[i];
arr[i] %= 2;
sumpref[i] = (sumpref[i - 1] + arr[i]) % 2;
if(sumpref[i] == 0) {
cnt_0++;
}
}
if(sumpref[n] == 1) {
cout << 0;
} else {
cout << (1 << (cnt_0 - 1));
}
cout << endl;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <bits/stdc++.h> #define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define debug(x) cerr << #x << " " << x << endl #define int long long #define st first #define nd second using namespace std; const int N(3e5 + 13); const int MAX(LLONG_MAX); const int MOD(1e9+7); int n, cnt_0; int arr[N], sumpref[N]; bool flag; string s; int32_t main() { boost; cin >> n; for (int i = 1; i <= n;i++) { cin >> arr[i]; arr[i] %= 2; sumpref[i] = (sumpref[i - 1] + arr[i]) % 2; if(sumpref[i] == 0) { cnt_0++; } } if(sumpref[n] == 1) { cout << 0; } else { cout << (1 << (cnt_0 - 1)); } cout << endl; } |
English