A,B,H,M = map(int, input().split())

import math
print(math.pi)

degreeA = (H * 60 + M) / 2
degreeB = M * 6

if degreeA == degreeB:
    print(abs(A - B))
else: #degreeA > degreeB:
    degreeAB = abs(degreeA - degreeB)
    if degreeAB == 180:
        print(A + B)
    elif degreeAB > 180:
        degreeAB = 360 - degreeAB
    C = A ** 2 + B ** 2 - 2 * A * B * math.cos(degreeAB * math.pi / 180)
    print(math.sqrt(C))