#include <bits/stdc++.h>
using namespace std;
int n;
const long long mod = 1000000007;
long long tab[300005];
void wstep()
{
cin >> n;
for (int i = 0; i < n; i++)
cin >> tab[i];
}
long long rozwiniecie()
{
long long ile = 0;
long long s = tab[0];
for (int i = 1; i < n; i++)
{
if (s % 2 == 0)
{
ile++;
s = tab[i];
}
else
s = (s + tab[i]) % mod;
}
if (s % 2 == 0ll)
ile++;
else
return -1ll;
return ile;
}
long long zakonczenie(long long a, long long b) // potęgowanie modularne
{
if (b < 0)
return 0ll;
long long i;
long long result = 1ll;
long long x = a % mod;
for (i = 1; i <= b; i <<= 1)
{
x %= mod;
if ((b & i) != 0)
{
result *= x;
result %= mod;
}
x *= x;
}
return result;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
wstep();
long long a = rozwiniecie();
cout << zakonczenie(2ll, a-1);
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #include <bits/stdc++.h> using namespace std; int n; const long long mod = 1000000007; long long tab[300005]; void wstep() { cin >> n; for (int i = 0; i < n; i++) cin >> tab[i]; } long long rozwiniecie() { long long ile = 0; long long s = tab[0]; for (int i = 1; i < n; i++) { if (s % 2 == 0) { ile++; s = tab[i]; } else s = (s + tab[i]) % mod; } if (s % 2 == 0ll) ile++; else return -1ll; return ile; } long long zakonczenie(long long a, long long b) // potęgowanie modularne { if (b < 0) return 0ll; long long i; long long result = 1ll; long long x = a % mod; for (i = 1; i <= b; i <<= 1) { x %= mod; if ((b & i) != 0) { result *= x; result %= mod; } x *= x; } return result; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); wstep(); long long a = rozwiniecie(); cout << zakonczenie(2ll, a-1); return 0; } |
English