题目地址:http://codeforces.com/contest/1196/problem/B
You are given an array aa consisting of nn integers a1,a2,…,an You want to split it into exactly kk non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to rearrange (shuffle) the elements of a given array. Each of the nn elements of the array aa must belong to exactly one of the kk subsegments.
Let's see some examples of dividing the array of length 5 into 3subsegments (not necessarily with odd sums): [1,2,3,4,5] is the initial array, then all possible ways to divide it into 3 non-empty non-intersecting subsegments are described below:
- [1],[2],[3,4,5][1],[2],[3,4,5];
- [1],[2,3],[4,5][1],[2,3],[4,5];
- [1],[2,3,4],[5][1],[2,3,4],[5];
- [1,2],[3],[4,5][1,2