Baklava Tray
Time limit12sMemory limit512 MB
For a regular N-gon of area 1, nested polygons join midpoints forever; find the expected total nut types hit by 10^4 random points.
- Level
Medium7 of 10
- Topics
- Math, Geometry, Probability, Combinatorics
- Solved
- No attempts yet
Problem
At the ACPC closing, the contestants decided to celebrate their hard work during the whole season by getting a very large tray of Baklava (Baklawa).
While waiting for the order, they started watching the baker making trays for other customers. They noticed that he first draws a regular N-sided polygon with area 1 and puts crushed hazelnut on the whole polygon, then he draws a second polygon inside it by joining the midpoints of the sides of the first one and puts cashews on this polygon. Then he continues with different types of nuts to draw an infinite sequence of N-sided polygons inside each other, and each of them is formed by joining the midpoints of the sides of the latest drawn polygon. Consequently, the outermost polygon contains one type of nuts (hazelnuts), the second polygon contains two types (hazelnuts and cashews), and so on. This way each polygon contains all the nuts of the polygons preceding it as well.
After the baker is done with the contestants' order, 104 persons with their forks will hit the tray at random places only once (yes, people from other hotels all over Sharm were excited about this tray). The deliciousness factor is then computed by summing the number of nut types hit by the fork of each person, and this is computed independently for each person. Note that if a person hits the ith innermost polygon, then he will hit exactly i nut types.
Help the Regional Contest Director determine the expected deliciousness factor for a tray with N sides.

The first three polygons for N = 5.
Input
The first line of the input contains a single integer T specifying the number of test cases.
Each test case consists of a single line containing a single integer N (3 ≤ N ≤ 800) representing the number of sides of the tray.
Output
For each test case, print a single line containing a single decimal number (rounded to exactly 5 decimal places) representing the expected deliciousness factor for the corresponding test case.
Your answer will be considered correct if it has an absolute or relative error less than 10−5.
Hint
A regular polygon of N sides is a polygon where all the sides are of the same length, and all the inner angles are the same.