E |
Count
the Polygons Input: Standard Input Output: Standard Output |
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.
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, 2^31), which represents the lengths of the available sticks. The integers are separated by a single space.
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.
4 4 3 10 10 20 20 6 4 1 1 1 1 1 1 4 3 10 20 30 100000000 6 6 2 3 4 5 6 7
|
Case 1: 2 |
Problem Setter: Sohel Hafiz
Special Thanks: