Given the circumference of a circle and the side lengths of an inscribed-tangent polygon whose vertices are equidistant from the circle, find the area between them.
Medium7GeometryMathImplementationBrute forceNo attempts yetTime limit3sMemory limit512 MBYour friend Donald has a villa surrounded by two tiers of fences, and he wants to know the area of the land between them. He can measure the length of any part of a fence, but he does not know how to compute the area. Watson, another friend of Donald, decided that the fences were built by someone who knows computational geometry, because the following three facts are no coincidence.
min(x,y)∈B(x−xu)2+(y−yu)2=min(x,y)∈B(x−xv)2+(y−yv)2
You are given the total length c of the outer tier and the lengths ℓ1,…,ℓn of the edges of P. Donald can measure all of these himself. Compute the area of the land between the two tiers.
The first line contains the number of test cases T. Each test case consists of two lines. The first line contains two numbers c and n separated by a space. c is the total length of the outer tier, that is, the perimeter of C, and n is the number of vertices of P. The second line contains the edge lengths ℓ1,…,ℓn of P.
For each test case, print the area of the land between the two tiers on its own line. Round the area to six digits after the decimal point and print all six digits, including trailing zeros.