Pagini recente » Cod sursa (job #2670021) | Cod sursa (job #1361045) | Cod sursa (job #2437812) | Cod sursa (job #1058410) | Cod sursa (job #1351255)
// azerah
#include <iostream>
#include <fstream>
#include <vector>
#define ll long long
#define mod 1000000007
#define pb push_back
using namespace std;
ifstream f("azerah.in");
ofstream g("azerah.out");
int n;
int pare, impare;
vector<int> A;
void gcd(int a, int b, int *x, int *y) {
if (b == 0) {
*x = 1;
*y = 0;
} else {
int x0, y0;
gcd(b, a%b, &x0, &y0);
*x = y0;
*y = x0 - (a/b)*y0;
}
}
long long inv(int x) {
int xs, ys;
gcd(x, mod, &xs, &ys);
if (xs <= 0) {
xs = mod + xs%mod;
}
return xs;
}
int fact(int p) {
int rez = 1;
for (int i=2;i<=p;i++)
rez *= i;
return rez;
}
long long comb(ll n, ll k) {
return ((fact(n) * inv(fact(k))%mod) * inv(fact(n-k)))%mod;
}
long long power(long long x, long long p) {
int cpy = x;
while (p > 1) {
p--;
x *= cpy;
x = x%mod;
}
return x;
}
void solve() {
pare = impare = 0;
f>>n;
for (int i=1;i<=n;i++) {
int x; f>>x;
if (x % 2 == 0) pare++;
else impare++;
A.pb(x);
}
ll rez = 0;
long long first = power(2, pare)-1;
long long second = 0;
for (int i=2;i<=impare;i+=2)
second += comb(i, impare);
rez = (((second+first)%mod)+((second*first)%mod));
g<<rez<<'\n';
}
int main() {
int t; f>>t;
while (t--) {
solve();
}
f.close(); g.close();
return 0;
}