Triangles
Time limit8sMemory limit512 MB
For each n up to 1000, find the area of the union of n unit equilateral triangles sharing a centroid, each rotated by 360/n degrees.
- Level
Medium6 of 10
- Topics
- Geometry, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
There is a group that paints an emblem on the ground every year to invite aliens. You are a member of this group, and this year you have to paint the emblem.
The shape of the emblem is as follows. It is made of n regular triangles whose sides are all one unit long. These triangles are placed so that their centroids coincide, and each is rotated counterclockwise by 360/n degrees with respect to the one below it around its centroid. The direction of the top triangle is not taken into account.
Emblems are believed to make a stronger impression as n grows. So you want to paint the emblem with n as large as possible, but you do not have enough chemicals. Write a program that outputs the area of the emblem for a given n so that you can estimate how much chemical is needed.

Figure 1: The emblem for n = 2
Input
The input consists of several data sets. Each data set is one line containing an integer n between 1 and 1000 inclusive.
The input ends with a line containing n = 0. This line is not processed.
Output
For each data set, output the area of the emblem on one line. You may output any number of digits after the decimal point. However, the error must be at most 10-6 ( = 0.000001).