#include<bits/stdc++.h> #define pb push_back #define int long long using namespace std; const int mod=1e9+7, N=3e5+9; //const int mod=1e2+7, N=3e5+9; int n, tab[N], sumka, sumka_all, ile; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=0; i<n; i++) cin>>tab[i]; for(int i=0; i<n; i++){ sumka=(sumka+tab[i])%mod; sumka_all=(sumka_all+tab[i])%mod; if(sumka%2==0){ sumka=0; ile++; } } if(sumka_all%2==0){ int potega=1; for(int i=0; i<ile-1; i++) potega=(potega*2)%mod; cout<<potega<<"\n"; } else cout<<"0\n"; 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 | #include<bits/stdc++.h> #define pb push_back #define int long long using namespace std; const int mod=1e9+7, N=3e5+9; //const int mod=1e2+7, N=3e5+9; int n, tab[N], sumka, sumka_all, ile; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=0; i<n; i++) cin>>tab[i]; for(int i=0; i<n; i++){ sumka=(sumka+tab[i])%mod; sumka_all=(sumka_all+tab[i])%mod; if(sumka%2==0){ sumka=0; ile++; } } if(sumka_all%2==0){ int potega=1; for(int i=0; i<ile-1; i++) potega=(potega*2)%mod; cout<<potega<<"\n"; } else cout<<"0\n"; return 0; } |