Fences
Time limit3sMemory limit512 MB
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.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Your 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.
- The land inside the outer tier is a perfect circle . Let be the set of points on the boundary of .
- The land inside the inner tier is a non-self-intersecting polygon with vertices. That is, two edges that share no vertex never intersect. Let be the set of vertices of .
- Every vertex of has the same minimum distance to . In other words, for any two distinct vertices ,
You are given the total length of the outer tier and the lengths of the edges of . Donald can measure all of these himself. Compute the area of the land between the two tiers.
Input
The first line contains the number of test cases . Each test case consists of two lines. The first line contains two numbers and separated by a space. is the total length of the outer tier, that is, the perimeter of , and is the number of vertices of . The second line contains the edge lengths of .
- are positive integers.
- A polygon satisfying the conditions above always exists for the given lengths, and lies inside the circle .
Output
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.