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
75
76
77
78
79
80
81
#include <iostream>
#include <vector>

constexpr uint32_t P = 1000000007;
using num_vect_t = std::vector<uint32_t>;

struct mop_t
{
	num_vect_t nums;

	friend std::istream& operator>>(std::istream& in, mop_t& m)
	{
		uint32_t size;
		in >> size;
		m.nums.reserve(size);
		for(uint32_t i = 0; i < size; ++i)
		{
			uint32_t val;
			in >> val;
			m.nums.emplace_back(val);
		}
		return in;
	}
	friend std::ostream& operator<<(std::ostream& out, mop_t const& m)
	{
		for (auto const& e : m.nums)
		{
			out << e << " ";
		}
		return out;
	}
};

bool meets_criteria(uint32_t val)
{
	return ! ((val % P) & 1);
}

uint32_t find_num_divs(std::ostream& out, num_vect_t const& nums, uint32_t first)
{
	uint32_t result = 0;
	auto it = nums.begin();
	it += first;
	uint32_t idx = 0;
	uint32_t sum = 0;
	for (;it!= nums.end();++it, ++idx)
	{
		sum += *it;
		if (meets_criteria(sum))
		{
			result += find_num_divs(out, nums, idx + first +1);
		}
	}
	if (it == nums.end() && sum > 0 && meets_criteria(sum))
	{
		result += 1;
	}
	if (result > P)
	{
		result = result % P;
	}
	return result;
}

uint32_t solution(std::istream& input, std::ostream& out)
{
	uint32_t result = 0;
	mop_t mop;
	input >> mop;
	result = find_num_divs(out, mop.nums, 0);
	out << result << std::endl;
	return result;
}

#ifndef TEST
int main(int argc, char* argv[])
{
	solution(std::cin, std::cout);
	return 0;
}
#endif