Odd subsequences

3.9

12 votes
Combinatorics, Mathematics, Dynamic Programming, 2D dynamic programming, Algorithms
Problem

You are given an array A consisting of N elements. Find the number of subsequences of length K with odd sum modulo 109+7.

Input format

  • The first line contains the number of test cases T
  • The first line of each test case contains two integers N denoting the number of elements in array A and K denoting the length of subsequence.
  • The second line of each test case contains N space-separated integers of array A.

Output format

Print T lines. For each test case:

  • Print a single integer denoting the number of subsequences of length K with odd sum modulo 109+7.

Constraints

  • 1T100
  • 1N1000
  • 1KN
  • 1Ai200
  • Sum of N over all test cases will not exceed 1000.
Sample Input
1
5 2
1 2 3 4 5
Sample Output
6
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

[1,2],[1,4],[2,3],[2,5],[3,4] and [4,5]

Editor Image

?