Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.
An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.
At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

-----Constraints-----
 - All values in input are integers.
 - 1 \leq A, B \leq 1000
 - 0 \leq H \leq 11
 - 0 \leq M \leq 59

-----Input-----
Input is given from Standard Input in the following format:
A B H M

-----Output-----
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}.

-----Sample Input-----
3 4 9 0

-----Sample Output-----
5.00000000000000000000

The two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.

Difficulty: introductory

Starter code:

Solutions:
import math
A,B,H,M = map(int,input().split())
if H >= 12:
    H -= 12
choperminute = 360/60 ##一分で長針が何度動くか
tanperminute = 30/60 ##一分で短針が何度動くか

tankaku = H*30 + tanperminute*M
chokaku = choperminute*M

if chokaku >= tankaku:
    angle = chokaku -tankaku
else:
    angle = tankaku - chokaku
    
if angle > 180:
    angle = 360 -angle
    
ansjyou = (A**2) + (B**2) - (2*A*B*math.cos(math.radians(angle)))
print(ansjyou**0.5)

import math
a, b, h, m = map(int, input().split())
t = math.pi * (60 * h - 11 * m) / 360
l = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(t))
print(l)

import math
[A, B, H, M] = [int(i) for i in input().split()]
x = 5.5*(60*H + M)
c = A**2 + B**2 -2*A*B*math.cos(math.radians(x))
print(c**0.5)

import math
pi=math.pi
a,b,h,m=map(int,input().split())
ra=((60*h+m)/360)*180
rb=(180/30)*m
r=abs(ra-rb)
if r>2*180:
    r=2*180-r
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(r*2*pi/360))
print(f'{ans:.20f}')

import math
a,b,h,m = list(map(int,input().split()))

minutes = m/60*2*math.pi
hour = (60*h+m)/720*2*math.pi

theta = abs(hour-minutes)


x = math.sqrt(a**2+b**2-2*a*b*math.cos(theta))
print(x)


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf, pi, cos
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

a, b, h, m = [int(i) for i in input().split()]

tmp = 0
res = 0

theta = 2 * pi * (h / 12.0 + m / 720.0 - m / 60.0)
res = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theta))

print(res)


import math

a, b, h,m = list(map(int,input().split()))

h_deg = (60 * h + m) * (360 / (60*12))
m_deg = m * (360 / 60)
deg = abs(h_deg-m_deg)
rad = math.radians(deg)

c = a ** 2 + b ** 2 - 2 * a * b  * math.cos(rad)

print((math.sqrt(c)))



import math

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

theta = abs((H + M / 60 ) / 12 - M / 60) * 2 * math.pi
#if theta > math.pi: theta -= math.pi

ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(theta))

print(ans)


import math

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

q = abs((H + M/60)/12-M/60)*360

print((math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(q)))))


import math

x = list(map(int,input().split()))

A = x[0]
B = x[1]
H = x[2]
M = x[3]

y = 2*math.pi*((H*60+M)/720-M/60)

z = math.sqrt(A**2+B**2-2*A*B*math.cos(y))

print(z)

import math
a,b,h,m = list(map(int,input().split()))

minutes = m/60*2*math.pi
hour = (60*h+m)/720*2*math.pi

theta = abs(hour-minutes)


x = math.sqrt(a**2+b**2-2*a*b*math.cos(theta))
print(x)


import math

a, b, h, m = list(map(int, input().split()))

x = 6 * m
y = 30 * h + 0.5 * m
C = max(x, y) - min(x, y)
C = min(C, 360 - C)

print((math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))))


import math
A, B, H, M = map(int, input().split())
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(30*H - 11*M/2)))
print(ans)

import math

A, B, H, M = list(map(int, input().split()))
rad = ((H / 12) - (M * 11 / 720)) * 2 * math.pi

ans = ((A ** 2) + (B ** 2) - (2 * A * B * math.cos(rad))) ** (1 / 2)
print(ans)

import math

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

angle = (H*30 + 30*(M/60))-M*6
abs_angle = abs(angle)

if abs_angle >180:
  abs_angle = 360 - abs_angle

abs_angle = math.cos(math.radians(abs_angle))
ans_sqrt = A**2 + B**2 - 2*A*B*abs_angle

print(math.sqrt(ans_sqrt))

import math as mt
a,b,h,m=list(map(int, input().split()))
print((mt.sqrt(a**2+b**2-2*a*b*mt.cos(2*mt.pi*(1/12*(h+m/60)-m/60)))))




#!/usr/bin/env python3

#import
import math
#import numpy as np
A, B, H, M = list(map(int, input().split()))

h = H * 30 + M / 2
m = M * 6
t = max(m, h) - min(m, h)
theta = min(t, 360 - t)
c = A**2 + B**2 - 2 * A * B * math.cos(theta / 180 * math.pi)
print((math.sqrt(c)))


import math

a, b, h, m = list(map(int, input().split()))

ang = h * 30 - m * 11/2

c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ang)))

print(c)


import math

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

h_theta = 2 * math.pi * (H+M/60)/12
m_theta = 2 * math.pi * M/60

dx = A * math.cos(h_theta) - B * math.cos(m_theta)
dy = A * math.sin(h_theta) - B * math.sin(m_theta)

print(math.sqrt(dx**2+dy**2))

import math
A, B, H, M = map(int, input().split())
thetaA = math.pi * (0.5*(H*60 + M)) / 180
thetaB = math.pi * 6.0*M / 180
theta = min(2*math.pi-abs(thetaA-thetaB), abs(thetaA-thetaB))
cosC = math.cos(theta)
ans = math.sqrt(A**2+B**2-2*A*B*cosC)
print(ans)

import math

a, b, h, m = map(int, input().split())
angle = ((h * 60 + m) / 720 - m / 60) * math.pi * 2  # 角度(ラジアン)
ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(angle))  # 余弦定理
print(ans)

import math
def i_input(): return int(input())


def i_map(): return list(map(int, input().split()))


def i_list(): return list(map(int, input().split()))


def i_row(N): return [int(input()) for _ in range(N)]


def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]
def degCal(hour,minite):
    ansDeg=0
    convHour=hour+minite/60
    angA=2*math.pi/12*convHour
    angB=2*math.pi*convHour
    ansDeg=abs(angA-angB)

    return ansDeg

def lenCal(deg,lenA,lenB):
    ansLen=math.sqrt(lenA**2+lenB**2-2*lenA*lenB*math.cos(deg))

    return ansLen

a,b,h,m= i_map()
angle=degCal(h,m)
ans=lenCal(angle,a,b)

print(ans)





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

at = (60*H+M)/(12*60)*2*math.pi
bt = M/60*2*math.pi
ax = A*math.sin(at)
ay = A*math.cos(at)
bx = B*math.sin(bt)
by = B*math.cos(bt)

print(((ax-bx)**2+(ay-by)**2)**0.5)

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


if H == 0:
    H = 12
elif M == 0:
    M = 60
L = M / 5



N = min(abs(L - H), abs(H - L))

if L >= H:
    if M == 60:
        M = 0
    S = 360 * N / 12 - (0.5 * M)
else:
    S = 360 * N / 12 + (0.5 * M)


ANS = A**2 + B**2 - (2*A*B*math.cos(math.radians(S)))
ANS = math.sqrt(ANS)
print(ANS)


import math

a,b,h,m = map(int, input().split())

m_radians = 360 * m / 60
h_radians = 360 * ((h * 5 + 5 * m / 60) / 60)

cos_ab = math.cos(math.radians(h_radians-m_radians))
c = math.sqrt(a**2 + b**2 - 2*a*b*cos_ab)

print(c)

import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    A, B, H, M = MI()
    pai = math.pi
    h = H / 12 + M / 720
    m = M / 60
    angle = abs(h-m)
    if angle > 0.5:
        angle = 1 - angle

    res = A**2 + B**2- 2*A*B*math.cos(math.radians(360*angle))
    print(math.sqrt(res))
def __starting_point():
    main()
__starting_point()

import math

a, b, h, m = list(map(int, input().split()))

ang = abs(h * 30 - m * 11/2)

c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ang)))

print(c)


import math
def main():
    a, b, h, m = map(int, input().split(" "))
    r1 = h*30 + m / 2
    r2 = 6 * m
    r3 = abs(r1-r2)
    print(math.sqrt(a **2 + b **2 -2*a*b*math.cos(math.radians(r3))))

def __starting_point():
    main()
__starting_point()

import math
A, B, H, M = map(int, input().split())
sitaH = (H*60+M) / 720 * 2 * math.pi
sitaM =  M/60 * 2 * math.pi

posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)

delX = posXH - posXM
delY = posYH - posYM

d = (delX*delX + delY*delY)**(1/2)
print(d)

from math import*

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

print((A*A+B*B-2*A*B*cos((M*11/360-H/6)*pi))**.5)

import math

def cal(H,M):

    H = 360/12*H + 1/12 * (M/60) *  360
    M = 360/60*M
    H_M = abs(H-M)

    if H_M > 180:
        H_M = 360 - H_M
    
    return H_M

def main():
    A, B, H, M = map(int,input().split())
    
    angle = cal(H,M)
    
    if angle == 180:
        print(A+B)
    
    else:
        print(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(angle))))
              
main()

from collections import Counter
import sys
import math

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    a, b, h, m = list(map(int, input().split()))
    x1 = a * math.cos(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
    y1 = a * math.sin(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
    x2 = b * math.cos(2 * math.pi * (m / 60))
    y2 = b * math.sin(2 * math.pi * (m / 60))

    print((((x1 - x2)**2 + (y1 - y2)**2)**(1/2)))


main()


import math
A,B,H,M = map(int,input().split())
h = (H/12+M/60/12)*360
m = (M/60)*360
r = min(abs(h-m),360-abs(h-m))
ans = (A**2+B**2-2*B*A*math.cos(math.radians(r)))**(1/2)
print(ans)

import math
a,b,h,m=map(int,input().split())
q= abs(m/60-(h+m/60)/12)*360
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(q))))

import math
def colon():
    A, B, H, M = map(int,input().split())
    h = 30 * H
    h = h - 5.5 * M
    h = min(h, 360 - h)
    h = h * math.pi / 180
    res = A**2 + B**2 - 2*A*B*math.cos(h)
    print(res**0.5)
    
colon()

import math
a,b,h,m =(float(x) for x in input().split())
x = (h*math.pi/6)+(m*math.pi/360)
y = (m*math.pi/30)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(x-y)))

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

s=float(max(6*M,30*H+1/2*M)-min(6*M,30*H+1/2*M))/180*math.pi
S=float(min(s,abs(s-180))/180*math.pi)
print(float(math.sqrt(A**2+B**2-2*A*B*math.cos(s))))

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A, B, H, M = na()
l = 360 / 12 * (H + M / 60)
s = 360 / 60 * M
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(abs(l - s) * math.pi / 180)))

import math
A,B,H,M=map(int,input().split())
C2=A**2+B**2-2*A*B*math.cos((30*H-11*M/2)/180*math.pi)
print(C2**(1/2))

a,b,h,m = map(int,input().split())
import math
H=30*h+0.5*m
M=6*m
C=a**2+b**2-2*a*b*math.cos(math.radians(H-M))
print(math.sqrt(C))

import math

a, b, h, m = map(int, input().split())
h_rad = (h * 60 + m) * math.pi / 360
m_rad = m * math.pi / 30
cosine = math.cos(abs(h_rad - m_rad))

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosine))

import math

a, b, h, m = map(int, input().split())

ha = (h*60+m)/360 * math.pi
ma = m/30 * math.pi
sh, ch = math.sin(ha), math.cos(ha)
sm, cm = math.sin(ma), math.cos(ma)
print(((a*sh-b*sm)**2+(a*ch-b*cm)**2)**(1/2))

import math
a,b,h,m=map(int,input().split())
lrad=6*m
srad=30*h+0.5*m
if abs(lrad-srad)<=180:
    do=abs(lrad-srad)
else:
    do=360-abs(lrad-srad)
rad=math.radians(do)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(rad)))

import math
a, b, h, m = map(int, input().split())
theta_h = 2 * math.pi * (h + m / 60) / 12
theta_m = 2 * math.pi * m / 60
d_theta = abs(theta_h - theta_m)
answer = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(d_theta))
print(answer)

import math
a,b,h,m=map(int,input().split())
x =(math.pi)*h/6 - (math.pi)*m/30 + (math.pi)*m/360
c = math.sqrt(a**2+b**2-2*a*b*(math.cos(x)))
print(c)

import numpy as np

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


angle_h = 1./ 12.*(H + M/60.) * 2*np.pi

angle_m = M/60. * 2 * np.pi

hour = (A*np.sin(angle_h), A*np.cos(angle_h))
minute = (B*np.sin(angle_m), B*np.cos(angle_m))

dist = np.sqrt((hour[0] - minute[0])**2 + (hour[1] - minute[1])**2)

print(dist)


import math
A,B,H,M=map(int,input().split())
s=float(max(6*M,30*H+1/2*M)-min(6*M,30*H+1/2*M))/180*math.pi
print(float(math.sqrt(A**2+B**2-2*A*B*math.cos(s))))

a,b,h,m = map(int, input().split())

import math
print((a**2+b**2-2*a*b*math.cos(math.radians((360*h/12+30*m/60)-360*m/60)))**(1/2))

import math
a, b, h, m = list(map(int, input().split()))

deg_m = (m / 60) * 360
deg_h = ((60 * h + m) / 720) * 360
deg = abs(deg_h - deg_m)
deg = math.radians(min(360 - deg, deg))
x2 = b ** 2 + a ** 2 - 2 * b * a * math.cos(deg)

print(x2**0.5)

import sys
import math
a,b,h,m=map(int,input().split())

f=h / 12 * 360 - m / 60 * 360 + m / 60 / 12 * 360

print((a**2+b**2-2*b*a*(math.cos(math.radians(f))))**(0.5))

import math
A,B,H,M = map(int,input().split())
V1 = 30
V2 = 30/60
v = 6
d = abs( (V1*H + V2*M) - v*M)
print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(d))))

import math
A,B,H,M=list(map(int,input().split()))
Hx=math.cos(((H/12)+((1/12)*(M/60)))*2*math.pi)*A
Mx=math.cos((M/60)*2*math.pi)*B
Hy=math.sin(((H/12)+((1/12)*(M/60)))*2*math.pi)*A
My=math.sin((M/60)*2*math.pi)*B

print((math.sqrt((Hx-Mx)*(Hx-Mx)+(Hy-My)*(Hy-My))))


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

x = H / 12 * 360 + M / 60 * 30
y = M / 60 * 360

ang = abs(y - x)
ans_2 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(ang))
ans = math.sqrt(ans_2)
print(ans)


import math
a,b,h,m=map(float,input().split())
#時針の角度をA
c=abs(30*h-11/2*m)
ct=math.radians(c)
cos=math.cos(ct)
ans=a**2+b**2-2*a*b*cos
print(math.sqrt(ans))

import math
a,b,h,m = map(int, input().split())
# A: 360 / 720 [degree/min]
# B: 360/ 60 [degree/min]
r_a = 30*h + 0.5 * m
r_b = 6 * m
rad = math.pi * (r_a-r_b)/180
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(rad))
print(ans)

import math
a,b,h,m = [int(x) for x in input().split()]
p = math.pi
arg_h = 2 * p * h / 12 + m * p / 360
arg_m = 2 * p * m / 60
arg = abs(arg_h - arg_m)
c_2 = a**2 + b**2 - 2 * a * b *math.cos(arg)
c = math.sqrt(c_2)
print(c)

import numpy as np
A,B,H,M = map(int,input().split())
pi = np.pi
h_angle = (H + M/60) * 2*pi / 12
m_angle = M * 2 * pi / 60
h_x = A * np.cos(h_angle)
h_y = A * np.sin(h_angle)
m_x = B * np.cos(m_angle)
m_y = B*np.sin(m_angle)
print(np.sqrt((h_x - m_x) ** 2 + (h_y - m_y) ** 2))

import math
A,B,H,M = map(int,input().split())
Btheta = M * math.pi / 30
Bx = B * math.cos(Btheta)
By = B * math.sin(Btheta)
Atheta = ((60 * H + M) / 360) * math.pi
Ax = A * math.cos(Atheta)
Ay = A * math.sin(Atheta)
print(((Ax - Bx) ** 2 + (Ay - By) ** 2) ** (1 / 2))

a,b,c,d=map(int,input().split())
c=(c*60+d)*0.5
d*=6
import math
ans=a**2+b**2-2*a*b*math.cos(math.radians(min(abs(d-c),360-(abs(d-c)))))
print(ans**0.5)

import numpy as np
a,b,h,m=map(int,input().split())
# print([a,b,h,m])

hour_theta= np.pi*(60*h+m)/360
minute_theta=np.pi*m/30

theta = abs(hour_theta-minute_theta)
# print(hour_theta)
# print(minute_theta)
# print(theta)
# print(np.cos(2.356194490192345))
ans=np.sqrt((a**2)+(b**2)-2*a*b*np.cos(theta))
print('{:.11f}'.format(ans))

import math

def main() -> None:
    a, b, h, m = list(map(int, input().split()))

    theta = abs(30*h - 5.5*m)
    cos_theta = math.cos(math.radians(theta))
    print(((a**2+b**2-2*a*b*cos_theta) ** 0.5))

    return


def __starting_point():
    main()

__starting_point()

import math
import numpy as np
a,b,h,m = list(map(int, input().split()))
a_radian = math.radians(h * 30 + m / 2)
a_ = np.array([a * math.cos(a_radian), a * math.sin(a_radian)])

b_radian = math.radians(6 * m)
b_ = np.array([b * math.cos(b_radian), b * math.sin(b_radian)])

print(np.linalg.norm(a_ - b_))

import math
a,b,H,M=map(int,input().split())
h=30*H+(0.5)*M
m=6*M
c=abs(h-m)
x=math.sqrt(a**2+b**2-(2*a*b*(math.cos(math.radians(c)))))
print(x)

import math
a,b,h,m=list(map(int,input().split()))

arg=min(abs(30*h-5.5*m), 360-abs(30*h-5.5*m))

print((math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(arg)))))


import math

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

angle_A = 6*M
angle_B = 30*(H+M/60)
angle_C = abs(angle_A-angle_B)

rad_C = math.radians(angle_C)

C = math.sqrt(A**2+B**2-2*A*B*math.cos(rad_C))

print(C)

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

import math

H_angle =(M * math.pi) / 30
M_angle = (60 * H + M) * math.pi / 360

H_x, H_y = (A * math.cos(H_angle), A * math.sin(H_angle))
M_x, M_y = (B * math.cos(M_angle), B * math.sin(M_angle))

d = math.sqrt((H_x - M_x) ** 2 + (H_y - M_y) ** 2)
print(d)

import math
a, b, h, m = map(int,input().split())
m_rad = m/60 * 360
h_rad = (h/12 * 360) + (m/60 * 360/12)
rad = abs(m_rad - h_rad)
ans = (a**2 + b**2) - (2 * a * b * math.cos(math.radians(rad)))
print(math.sqrt(ans))

import math
a, b, h, m = list(map(int, input().split()))
ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.pi*(h/6 + m/360 - m/30)))
print(ans)


import math
from decimal import Decimal
hour_len, minute_len, hour, minute = list(map(int, input().split()))

rad_h = math.radians( Decimal( (hour * 60 + minute) / 720 * 360 ) )
rad_m = math.radians( Decimal(minute / 60 * 360) )
cos_hm = math.cos( abs( Decimal(rad_h - rad_m) ) )

a_double = hour_len ** 2 + minute_len ** 2 - (2 * hour_len * minute_len * cos_hm)
ans = math.sqrt(a_double)
print( f"{ans:.20f}" )

import math

a, b, h, m = map(int, input().split())

alpha = 2*math.pi * h/12 + (math.pi/6) *m/60
beta = 2*math.pi * m/60

ans = (a*a + b*b - 2*a*b*math.cos(alpha - beta)) **0.5
print(ans)

a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
e=60*c+d
f=abs(0.5*e-6*e)
f=f%360
if f>180:
  f=360-f
import math
print(math.sqrt(a*a+b*b-2*a*b*(math.cos(math.radians(f)))))

import math
from decimal import Decimal
hour_len, minute_len, hour, minute = list(map(int, input().split()))

degree_hm = abs(((hour * 60 + minute) * 0.5) - (minute * 6))
rad_hm = math.radians(degree_hm) # 長針は1分で0.5deg、短針は1分で6deg
cos_hm = math.cos(rad_hm)

a_double = hour_len ** 2 + minute_len ** 2 - (2 * hour_len * minute_len * cos_hm)
ans = math.sqrt(a_double)
print( f"{ans:.20f}" )

# C - : (Colon)

import math

a,b,h,m = list(map(int,input().split()))

s = 3600*h + 60*m
radh = ((s/(60*60*12))-int(s/(60*60*12)))*2*math.pi
radm = ((s/(60*60))-int(s/(60*60)))*2*math.pi

c = math.sqrt(a**2+b**2-2*a*b*math.cos(radh-radm))

print(c)


from math import (pi,cos,sqrt,radians)

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

    # 長針、短針の0時0分からの角度を求める
    HTheta = H/12 * 360 + 1/12 * (M/60) *  360
    MTheta = M/60 * 360
    # |長針-短針|で角度θを求める
    Theta = abs(HTheta - MTheta) 
    # θ=180ならA+Bを出力して終了
    if Theta == 180:
        print(A + B)
        return
    # 予言定理を求める
    print(sqrt(A*A + B*B - 2*A*B*cos(radians(Theta))))

main()

import numpy as np
a,b,h,m = list(map(int,input().split()))

theta = abs(h/12-11*m/720)*2*np.pi
print(np.sqrt((a*a+b*b-2*a*b*np.cos(theta))))

import math
import numpy as np

# tはラジアン
def rot_rev(t, v):
    R = np.array([[ np.cos(t), np.sin(t)],
                  [-np.sin(t), np.cos(t)]])
    return np.dot(R, v)

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

# h時m分を 60*h + m 分に換算し、割合を計算
H_rad = ((H * 60 + M) / (12 * 60)) * 2 * np.pi
M_rad = (M / 60) * 2 * np.pi

P_A = (0, A)
P_B = (0, B)

rot_A = rot_rev(H_rad, P_A)
rot_B = rot_rev(M_rad, P_B)

print((np.linalg.norm(rot_A - rot_B)))


import math

a, b, h, m = list(map(int, input().split()))

ang = h * 30 - m * 5.5

ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ang)))

print(ans)


import math

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

thetaA = (math.pi * H / 6) + (math.pi * M / 360)
thetaB = (math.pi * M / 30)
Ax = A * math.cos(thetaA)
Ay = A * math.sin(thetaA)
Bx = B * math.cos(thetaB)
By = B * math.sin(thetaB)

X = Ax - Bx
Y = Ay - By

ans = (X ** 2 + Y ** 2) ** 0.5

print(ans)

from math import *
def calcAngle(h,m):
         
        # validate the input
        if (h < 0 or m < 0 or h > 12 or m > 60):
            print('Wrong input')
         
        if (h == 12):
            h = 0
        if (m == 60):
            m = 0
            h += 1;
            if(h>12):
                   h = h-12;
         
        # Calculate the angles moved by 
        # hour and minute hands with 
        # reference to 12:00
        hour_angle = 0.5 * (h * 60 + m)
        minute_angle = 6 * m
         
        # Find the difference between two angles
        angle = abs(hour_angle - minute_angle)
         
        # Return the smaller angle of two 
        # possible angles
        angle = min(360 - angle, angle)
         
        return angle
a,b,h,m=[int(i) for i in input().split()]
theta=calcAngle(h,m)*pi/180
ans=(a**2+b**2-2*a*b*cos(theta))**(1/2)
print(("{:.15f}".format(ans)))


import sys
import math
from decimal import Decimal
def input(): return sys.stdin.readline().rstrip()

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

minute = H * 60 + M
short = minute / (60 * 12) * 2 * math.pi
long = M / 60 * 2 * math.pi
rad = abs(long - short) 

ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))
print(ans)

import math
import numpy as np

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

thetaA = math.radians(((H / 12) + (1 / 12 * M / 60)) * 360)
thetaB = math.radians(M / 60 * 360)

a = np.array([A * math.sin(thetaA), A * math.cos(thetaA)])
b = np.array([B * math.sin(thetaB), B * math.cos(thetaB)])

print((round(np.linalg.norm(a - b), 11)))


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

# 時針: 12時間720分で360度 1分で0.5度
# 分針: 60分で360度 1分で6度
theta = abs(((0.5 * (H * 60 + M)) - (6 * M)) % 360)
if theta > 180:
  theta = 360 - theta
#print(theta)
import math
C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta / 180 * math.pi))
print(C)

# -*- coding: utf-8 -*-
"""
Created on Sun Sep  6 12:21:24 2020

@author: liang
"""
import math
pi = 3.141592653589793238
h, m, H, M = map(int,input().split())

print(math.sqrt(h**2+m**2-2*h*m*math.cos(2*pi*(30*H-5.5*M)/360)))

import math

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

M_deg = M / 60 * 360
H_deg = (H / 12 * 360) + (M_deg / 12)


deg = min(abs(H_deg - M_deg), abs(M_deg - H_deg))

rad = math.radians(deg)

ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))

print(ans)

from math import cos, radians


def answer(a: int, b: int, h: int, m: int) -> float:
    num = abs((60 * h - 11 * m) / 2)
    theta = min(num, 360 - num)
    return pow(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(radians(theta)), 1 / 2)


def main():
    a, b, h, m = map(int, input().split())
    print(answer(a, b, h, m))


def __starting_point():
    main()
__starting_point()

from cmath import *
A,B,H,M=map(int,input().split());print(abs(rect(A,pi*(H+M/60)/6)-rect(B,pi*M/30)))

import math
A, B, H, M = map(int,input().split())
h = 30*H + (0.5)*M
m = 6*M
C = abs(h-m)
X = math.sqrt(A**2 + B**2 -(2*A*B*(math.cos(math.radians(C)))))
print(X)

import math
 
A, B, H, M = map(int, input().split())
 
angle_A = 6*M
angle_B = 30*(H+M/60)
angle_C = abs(angle_A-angle_B)
 
rad_C = math.radians(angle_C)
 
C = math.sqrt(A**2+B**2-2*A*B*math.cos(rad_C))
 
print(C)

import math

A, B, H, M = map(int, input().split())
k = M / 60
if H == 0:
    H = 12
if M == 0:
    M = 60

H_d = ((H/12 * 60 + k*5)/60)*2*math.pi
M_d = (M/60)*2*math.pi
r = abs(H_d-M_d)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(r)))

import math

a, b, h, m = list(map(int, input().split()))

ang = abs(h * 30 - m * 11/2)
angle = min(ang, 360-ang)

c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle)))

print(c)


import math
A,B,H,M=map(int,input().split())
x=2*math.pi*abs(H/12+M/60/12-M/60)
ans=pow(A*A+B*B-2*A*B*math.cos(x),1/2)
print(ans)

import math
a,b,h,m=map(int,input().split())
c = 2*math.pi * (h *60 +m)/720
d = 2*math.pi * (m / 60)
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(c-d)))

A,B,H,M=map(float,input().split())
import math
rad_min =2.0*math.pi*M/60
rad_hour = 2.0*math.pi*H/12.0+math.pi/6.0*M/60.0
rad=abs(rad_min-rad_hour)
l=math.sqrt(A**2+B**2-2.0*A*B*math.cos(rad))
print(l)

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

wa=math.pi*2/60/12
wb=math.pi*2/60
theta=(wb-wa)*(H*60+M)%(2*math.pi)

print(((A**2+B**2-2*A*B*math.cos(theta))**0.5))


import math
a, b, h, m = list(map(int, input().split()))
ang = abs(h * 30 + m * 0.5 - m * 6)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(ang * math.pi / 180)))

import math
A, B, H, M = list(map(int, input().split()))
theta = (M * 11 / 360 - H / 6) * math.pi
print(((A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)) ** 0.5))
return


import numpy as np
a,b,h,m = list(map(int,input().split()))
pos1 = [b*np.sin(np.radians(6*m)),b*np.cos(np.radians(6*m))]
pos2 = [a*np.sin(np.radians(30*h+m*(360/(12*60)))),a*np.cos((np.radians(30*h+m*(360/(12*60)))))]
d = ((pos1[0]-pos2[0])**2+(pos1[1]-pos2[1])**2)**0.5
print(d)
#print(pos1)
#print(pos2)


import math
A,B,H,M = map(int,input().split())
a = (H*60+M)*0.5
b = M*6
angle = math.radians(min(abs(b-a),360-abs(b-a)))
cos = math.cos(angle)
ans = A**2 + B**2 - 2*A*B*cos
print(ans**0.5)

import math
a,b,h,m = list(map(int,input().split()))

total_minute = 60 * h + m

ax = a * math.cos(math.radians(360-(total_minute/2)+ 90))
ay = a * math.sin(math.radians(360-(total_minute/2)+ 90))
bx = b * math.cos(math.radians(360-(6*m) + 90))
by = b * math.sin(math.radians(360-(6*m) + 90))

kyori = math.sqrt((ax-bx)**2 + (ay-by)**2)

print(kyori)