Count the Polygons

A polygon is a plane figure that is bounded by a closed path and composed of a finite sequence of straight line segments. These segments are called its edges, and the points where two edges meet are the polygon’s vertices. You have got a set of N sticks of various lengths. How many ways can you choose K sticks from this set and form a polygon with K sides by joining the end points. Input The first line of input is an integer T (T < 100) that indicates the number of test cases. Each case starts with a line containing 2 positive integers N and K (3 ≤ N ≤ 30 & 3 ≤ K ≤ N). The next line contains N positive integers in the range [1,231), which represents the lengths of the available sticks. The integers are separated by a single space. Output For each case, output the case number followed by the number of valid polygons that can be formed by picking K sticks from the given N sticks. Sample Input 4 43 10 10 20 20 64 111111 43 10 20 30 100000000 66 234567 Sample Output Case 1: 2 Case 2: 15 Case 3: 0 Case 4: 1