Pyramids (Codeforces 630Q)
Tags: Math, geometry

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: 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: Output one number — the total volume of the pyramids. Absolute or relative error should not be greater than 10 - 9.


Sample Inputs:
2 5 3

Sample Outputs:
38.546168065709

Solution (Python):
import math
(a, b, c) = map(float, input().split())
num3 = 2 ** 0.5 / 12 * a ** 3
num4 = 2 ** 0.5 / 6 * b ** 3
cos = math.radians(72)
cos72 = abs(math.cos(cos))
t = math.radians(36)
tan36 = abs(math.tan(t))
x = (c ** 2 / (2 * (1 - cos72))) ** 0.5
h = (c ** 2 - x ** 2) ** 0.5
hh = c / 2 / tan36
di = c * hh * 5 / 2
num5 = di * h / 3
print(num3 + num4 + num5)

Solution (Python):
from math import tan, pi, sqrt

def ctg(x):
    return 1 / tan(x)
(l3, l4, l5) = map(int, input().split())
R = l3 / sqrt(3)
h = sqrt(l3 ** 2 - R ** 2)
S = l3 ** 2 * (sqrt(3) / 2) / 2
v3 = 1 / 3 * h * S
R = sqrt(l4 ** 2 + l4 ** 2) / 2
h = sqrt(l4 ** 2 - R ** 2)
S = l4 ** 2
v4 = 1 / 3 * h * S
R = sqrt(10) * sqrt(5 + sqrt(5)) / 10 * l5
h = sqrt(l5 ** 2 - R ** 2)
S = 5 / 4 * l5 ** 2 * ctg(pi / 5)
v5 = 1 / 3 * h * S
print(v3 + v4 + v5)

Solution (Python):
from math import *
(a, b, c) = map(int, input().split())
sa = pow(a, 3) * sqrt(2) / 12
sb = pow(b, 3) * sqrt(2) / 6
cc = sqrt(c * c - pow(c / 2 / sin(pi / 5), 2))
S = c / 2 * c / 2 / tan(pi / 5) * 5
sc = cc * S / 3
ans = sa + sb + sc
print(f'{ans}')