//author Karolina Miśkiewicz
#include<bits/stdc++.h>
using namespace std;
int len = 1000000000 + 7;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
vector<int> v,k;
int n;
cin >> n;
for(int i = 0; i < n; i++)
{
int temp = 0;
int a;
cin >> a;
for(int j = 0; j < v.size(); j++)
{
v[j] = (v[j] + a) % len;
if(v[j]%2 == 0)
{
if(j-1 >= 0)
temp = (temp + k[j-1])%len; // j - i
else
temp = (temp + 1)%len;
}
}
if(a%2 == 0)
{
if(i > 0)
{
temp = (temp + k[i-1])%len;
}
else
temp = (temp + 1)%len;
}
k.push_back(temp%len);
v.push_back(a);
}
cout << k[k.size()-1]%len;
}
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 | //author Karolina Miśkiewicz #include<bits/stdc++.h> using namespace std; int len = 1000000000 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); vector<int> v,k; int n; cin >> n; for(int i = 0; i < n; i++) { int temp = 0; int a; cin >> a; for(int j = 0; j < v.size(); j++) { v[j] = (v[j] + a) % len; if(v[j]%2 == 0) { if(j-1 >= 0) temp = (temp + k[j-1])%len; // j - i else temp = (temp + 1)%len; } } if(a%2 == 0) { if(i > 0) { temp = (temp + k[i-1])%len; } else temp = (temp + 1)%len; } k.push_back(temp%len); v.push_back(a); } cout << k[k.size()-1]%len; } |
English