Arrange the K rods around a shared point with equal spacing to maximize the sum of adjacent triangle areas.
Medium4Brute forceGeometryMathNo attempts yetTime limit5sMemory limit512 MBThe explorer Pascal found a device that an ancient civilization left behind for talking to aliens, and he worked out how to use it. The antenna of the device is built from K elements. An element is a straight rod made of a special material. One end of an element is its plus pole, the other end is its minus pole. The elements are numbered from 1 to K.
The antenna works only when it is assembled so that all four conditions below hold.
The angles add up to exactly one full turn, so the elements sit around the junction in a ring and there are exactly K pairs of neighboring elements. Take one such pair: the two minus poles and the junction form a triangle. The strength of the antenna is the sum of the areas of those K triangles.
Compute the largest strength that an arrangement of the elements reaches.
An element is thin enough that its thickness is ignored. You cannot cut an element, and you cannot join several elements into one.
The first line has a positive integer T, the number of test cases. Each test case has this format.
K
E1 E2 ... EK
K is the number of elements. Ei is a positive integer, the length of element i.
For each test case print one line in this format.
Case #X: P
X is the test case number starting from 1, and P is the largest strength. Print P rounded to six digits after the decimal point, padded with zeros. A strength of 2 is written 2.000000.