Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include<bits/stdc++.h>
- #include<iostream>
- #include<fstream>
- #include<vector>
- #include<map>
- #define long long long
- #define nln '\n'
- const long N = 100, MOD = 1e9 + 7;
- using namespace std;
- // Global variables: f1, f2, n, a, p
- fstream f1, f2;
- inline void openf()
- {
- f1.open("coin.inp", ios:: in);
- f2.open("coin.out", ios:: out);
- }
- inline void closef()
- {
- f1.close();
- f2.close();
- }
- long n, p;
- vector<long> a;
- void data()
- {
- f1.tie(0)->sync_with_stdio(0);
- f2.tie(0)->sync_with_stdio(0);
- cin.tie(0)->sync_with_stdio(0);
- cin >> n >> p;
- for (long i = 0; i != n; ++i)
- {
- long x;
- cin >> x;
- a.push_back(x);
- }
- }
- long odd = 0, eve = 1;
- void process()
- {
- for (long i = 0; i != n; ++i)
- {
- if (a[i] % 2)
- {
- long tem = odd;
- odd += eve % MOD;
- eve += tem % MOD;
- }
- else
- {
- odd += odd % MOD;
- eve += eve % MOD;
- }
- }
- }
- void view()
- {
- if (p == 1)
- cout << odd % MOD << nln;
- else
- cout << eve % MOD << nln;
- }
- int main()
- {
- openf();
- data();
- process();
- view();
- closef();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment