#define ll long long
#include <iostream>
#include<vector>
using namespace std;
ll m = 1000000007;
ll power(ll x, ll y){
int odp = 1;
x = x % m;
if (x == 0) return 0;
while (y > 0){
if (y & 1)
odp = (odp*x) % m;
y = y>>1;
x = (x*x) % m;
}
return odp%m;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n; cin>>n;
vector<ll>tab(n);
ll np=0;
for(int i = 0;i<n;++i){
cin>>tab[i];
np+=tab[i]%2;
}
if(np%2==1){
cout<<0;
return 0;
}
ll ile = 0,akt=0,odp=0;
for(int i = 0;i<n;++i){
if(tab[i]%2==0){++ile; continue;}
akt=0;
int j=i+1; bool found = false;
while(j<n){
if(tab[j]%2==1){
found=true;
break;
}
++j;
}
if(found)++ile;
i=j;
}
odp = power(2,ile-1);
cout<<odp;
return 0;
}
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 40 41 42 43 44 45 46 47 48 49 50 51 52 | #define ll long long #include <iostream> #include<vector> using namespace std; ll m = 1000000007; ll power(ll x, ll y){ int odp = 1; x = x % m; if (x == 0) return 0; while (y > 0){ if (y & 1) odp = (odp*x) % m; y = y>>1; x = (x*x) % m; } return odp%m; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin>>n; vector<ll>tab(n); ll np=0; for(int i = 0;i<n;++i){ cin>>tab[i]; np+=tab[i]%2; } if(np%2==1){ cout<<0; return 0; } ll ile = 0,akt=0,odp=0; for(int i = 0;i<n;++i){ if(tab[i]%2==0){++ile; continue;} akt=0; int j=i+1; bool found = false; while(j<n){ if(tab[j]%2==1){ found=true; break; } ++j; } if(found)++ile; i=j; } odp = power(2,ile-1); cout<<odp; return 0; } |
English