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
#include <stdio.h>
// using namespace std;
typedef long long ll;
constexpr ll M = 1000000007;
int main(void) {
	bool is_nomodulo = true;;
	size_t N; scanf("%lu", &N);
	ll *prefix = new ll[N];
	for (size_t i = 0; i < N; ++i) {
		scanf("%lli", &prefix[i]);
		if (prefix[i] > 100)
			is_nomodulo = false;
		if (i != 0)
			prefix[i] = (prefix[i-1] + prefix[i]) % M;
	}

	if (!is_nomodulo) {
		// Second Subtask
		ll *dp = new ll[N];
		if (prefix[0] % 2 == 0)
			dp[0] = 1;
		for (size_t i = 1; i < N; ++i) {
			dp[i] = 0;
			if (prefix[i] % 2 == 0)
				dp[i] += 1;
			for (size_t j = 0; j < i; ++j) {
				if ( (prefix[i] - prefix[j] + M)%M%2 == 0 )
					// dp[i] += dp[j];
					dp[i] = (dp[i] + dp[j])%M;
			}
		}
		printf("%lli\n", dp[N-1]);
	} else {
		// First Subtask
		ll result = 0;
		// if (prefix[N-1] % 2 == 1)
		// 	result = 0;
		// else
		// 	result = 1;
		for (size_t i = 0; i < N; ++i) {
			if (prefix[i] % 2 == 0) {
				if (result == 0)
					result = 1;
				else
					// result *= 2;
					result = (result * 2) %M;
			}
		}
		if (prefix[N-1] % 2 == 1)
			result = 0;

		printf("%lli\n", result);
	}

	return 0;
}