Pyramids
Contest: Experimental Educational Round: VolBIT Formulas Blitz
Difficulty rating: 1700
Tags: geometry, math

IT City administration has no rest because of the fame of the Pyramids in Egypt. There is a project of construction of pyramid complex near the city in the place called Emerald Walley. The distinction of the complex is that its pyramids will be not only quadrangular as in Egypt but also triangular and pentagonal. Of course the amount of the city budget funds for the construction depends on the pyramids' volume. Your task is to calculate the volume of the pilot project consisting of three pyramids — one triangular, one quadrangular and one pentagonal.

The first pyramid has equilateral triangle as its base, and all 6 edges of the pyramid have equal length. The second pyramid has a square as its base and all 8 edges of the pyramid have equal length. The third pyramid has a regular pentagon as its base and all 10 edges of the pyramid have equal length.

Input format:
The only line of the input contains three integers l3, l4, l5 (1 ≤ l3, l4, l5 ≤ 1000) — the edge lengths of triangular, quadrangular and pentagonal pyramids correspondingly.

Output format:
Output one number — the total volume of the pyramids. Absolute or relative error should not be greater than 10 - 9.

Constraints:
Time limit: 0.5 s
Memory limit: 64.0 MB

Example input:
2 5 3

Example output:
38.546168065709

Editorial:
The volume of a pyramid can be calculated as $$v = \frac{1}{3}sh$$ where v is the volume, s is the area of the base and h is the height from the base to the apex. Let's calculate s and h.
The area of a regular polygon having n sides of length ln can be found the following way.
On the figure above a regular polygon is shown. O is the center of the polygon, all sides are equal to ln, OB is the altitude of AOC triangle. As the polygon is a regular one OA = OC, AOC triangle is a isosceles one and then $$\angle A O B = \angle C O B$$ and AB = BC, also AOB and COB triangles are right-angled ones. Also because the polygon is a regular one and can be seen as a union of 2n triangles equal to AOB triangle then $$\angle AOB = \frac{2\pi}{2n} = \frac{\pi}{n}$$.
AOB triangle is right-angled one, so $$\tan \angle AOB = \frac{AB}{OB}$$, $$\sin \angle AOB = \frac{AB}{OA}$$. Also $$AB = \frac{l_n}{2}$$. So $$OB = \frac{l_n}{2\tan\frac{\pi}{n}}$$ and $$OA = \frac{l_n}{2\sin{\frac{\pi}{n}}}$$. The area of AOB is equal to $$\frac{1}{2}AB \cdot OB = \frac{1}{2} \cdot \frac{l_n}{2} \cdot \frac{l_n}{2 \tan \frac{\pi}{n}} = \frac{l_n^2}{8 \tan \frac{\pi}{n}}$$. The area of the polygon is $$s = 2n \frac{l_n^2}{8 \tan \frac{\pi}{n}} = \frac{l_n^2 \cdot n}{4 \tan \frac{\pi}{n}}$$.
On the figure above a triangle formed by the pyramid apex H, the center of the base O and some vertex of the base A is shown. It is a right-angled one. As all edges of the pyramid are equal, AH = ln and from calculations above $$OA = \frac{l_n}{2\sin{\frac{\pi}{n}}}$$. According to Pythagorean theorem OA2 + OH2 = AH2. So $$OH = \sqrt{AH^2 - OA^2} = \sqrt{l_n^2 - \frac{l_n^2}{4\sin^2\frac{\pi}{n}}} = l_n\sqrt{1 - \frac{1}{4\sin^2\frac{\pi}{n}}}$$.
The volume of one piramid is $$\frac{1}{3} \cdot \frac{l_n^2 \cdot n}{4 \tan \frac{\pi}{n}} \cdot l_n \sqrt{1 - \frac{1}{4 \sin^2 \frac{\pi}{n}}} = \frac{l_n^3 \cdot n}{12 \tan \frac{\pi}{n}} \sqrt{1 - \frac{1}{4 \sin^2 \frac{\pi}{n}}}$$.
And the final formula is $$\frac{l_{3}^{3}\cdot 3}{12\tan \frac{\pi }{3}}\sqrt{1-\frac{1}{4\sin ^{2}\frac{\pi }{3}}}+\frac{l_{4}^{3}\cdot 4}{12\tan \frac{\pi }{4}}\sqrt{1-\frac{1}{4\sin ^{2}\frac{\pi }{4}}}+\frac{l_{5}^{3}\cdot 5}{12\tan \frac{\pi }{5}}\sqrt{1-\frac{1}{4\sin ^{2}\frac{\pi }{5}}}$$.