peterverebics/CodeNet_Python_118 huggingface dataset:
import sys
import math

input = sys.stdin.readline
sys.setrecursionlimit(4100000)


def main():
    A, B, H, M = map(int, input().rstrip().split())
    theta_m = 2 * math.pi * M / 60
    theta_h = 2 * math.pi * (H * 60 + M) / (12 * 60)
    theta = (theta_h - theta_m) % math.pi
    ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
    print(theta_m)
    print(theta_h)
    print(theta)
    print(ans)


if __name__ == '__main__':
    main()
import math
a,b,h,m = map(int,input().split())
c = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(abs(30*h-6*m))))
print(c)
import math

A,B,H,M  = map(int,input().split())
hd = 30*H + int(30/60*M)
md = 6*M
dif = min(abs(hd - md), 360-abs(hd-md))
yo = A**2 + B**2 - 2*A*B*math.cos(math.radians(dif))
print(yo**0.5)
a,b,h,m = map(int,input().split())
t = 60 * h + m#経過時間
aa = divmod(t / 360,2) 
bb = divmod(t / 30,2)
aaa = aa[1]
bbb = bb[1]
import math
if aaa >= bbb:
    θ = (aaa - bbb)
else:
    θ = (bbb - aaa)
theta = divmod(θ,1)
theta1 = theta[1] * math.pi
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta1))
print(c)
import math
A, B, H, M = map(int, input().split())
long_deg = M*60
short_deg = M/2+H*30
rad = (long_deg - short_deg)*2*math.pi/360
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad)))
import math

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

hm = H + M / 60
h = hm * 30
m = M * 6

sa = abs(h - m)
if sa >= 180:
    sa = sa - 180

ans = (A**2 + B**2 - A * B * math.cos(math.radians(sa)) * 2) ** 0.5

if int(sa) == 0:
    if int(h) == int(m):
        ans = abs(A - B)
    else:
        ans = A + B

print(ans)
import math

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

h_rad = 30*h
m_rad = 0.5*m
diff1 = abs(h_rad-m_rad)
diff2 = 360-diff1
diff = min(diff1,diff2)
cos = math.cos(math.radians(diff))
ans = math.sqrt(a**2+b**2-(2*a*b*cos))
print(ans)
import math
A,B,H,M = list(map(int,input().split()))
Q = 30*H - 6*M
L = (A**2 + B**2 - 2*A*B*math.cos(math.radians(Q)))**(1/2)
print(L)
import math
a,b,h,m=map(int,input().split())
h=h*30+(m/60)*30
m=m*6
diff=abs(h-m)*((math.pi)/180)
if(diff>180):
    diff=diff-180
ans=a*a+b*b-2*a*b*abs(math.cos(diff))
print(math.sqrt(ans))
import math
a,b,hour,min = map(int,input().split())

def yogen(a,b,theta):
    result = a**2 + b**2 - 2*a*b*math.cos(theta)
    return math.sqrt(result)

theta = math.radians(360*abs(hour/12 - min/60))
print(yogen(a,b,theta))
import math

a, b, h, m = map(int, input().split())
l = m * 6
s = m * 0.5 + h * 30
th = abs(l - s)
if th == 0:
    print('{:.20f}'.format(abs(a - b)))
    exit()
elif th == 180:
    print('{:.20f}'.format(a + b))
    exit()
if th >= 180:
    th -= 180
cos = math.cos(math.radians(th))
ans = a**2 + b**2 - 2 * a * b * cos
print('{:.20f}'.format(math.sqrt(ans)))
import math

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

kakudo = abs((H*30+0.5*M-M*6)%180) 

if kakudo == 0:
    print(0)
else:
    a = (A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo)))
    print(math.sqrt(a))
import math
a, b, h, m = map(int, input().split())
# 角度を求める
H = 30 * h + (m/2)
M = 6 * m
theta = abs(H-M)
if theta == 0 or theta == 360:
  print(abs(a-b))
  exit()
if theta > 180:
  theta = theta - 180
#print(a, b, H, M, theta, math.sin(theta), math.cos(theta), math.tan(theta), math.sin(math.radians(theta)), math.cos(math.radians(theta)), math.tan(math.radians(theta)))
l = a * a + b * b - 2 *a*b* math.cos(math.radians(theta))
print(math.sqrt(round(l,9)))
import sys
import os
import math

def file_input():
    f = open('ABC168/input.txt', 'r')
    sys.stdin = f

def main():
    if os.getenv("ENV")=='LOCAL':
        file_input()

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

    A_r=360*(H*60+M)/(12*60)
    B_r=M*360/60

    dif=abs(A_r-B_r)
    if dif>180:
        dif-=180

    # print(math.cos(dif))
    ans=math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(dif)))

    print(ans)

if __name__ == '__main__':
    main()
import math
 
a, b, h, m = map(int, input().split())
 
r = abs((h * 30 + m * 0.5) - m * 6)
if r > 180:
    r = r - 180
 
c = float(math.sqrt(float(a**2 + b**2) - float(2 * a * b) * float(math.cos(math.radians(r)))))
print(c)
import math


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


d = 30*(h+m/60)-6*m
e = 360-d
f = int(min(d,e))
y = math.cos(math.radians(f))


x = a**2+b**2-2*a*b*y
print(math.sqrt(x))
import math
A, B, H, M = map(int,input().split())
degunit1 = 360/720
degunit2 = 360/60
currentHM = 60*H+M
deg1 = degunit1*currentHM
deg2 = degunit2*M
diff = abs(deg1-deg2)
if diff <=180:
  diff = diff*math.pi/180
else:
  diff = (diff-180)*math.pi/180
L = (A**2+B**2 -2*A*B*math.cos(diff))**0.5
print(L)
import math

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

hangle = float((h/12)*360)
hangle += (m/60)*30
mangle = float((m/60)*360)

if hangle > 180:
    hangle = hangle-180
if mangle > 180:
    mangle = mangle-180

angle = abs(hangle-mangle)
rad = math.radians(angle)

ans = float(math.sqrt(a*a + b*b - float(2*a*b*math.cos(rad))))

print(ans)
import math
a, b, h, m = map(int, input().split())
m_rad = 6 * m
h_rad = 30 * h + m / 2
rad = abs(h_rad - m_rad)
rad = rad
if rad > 180:
    rad = 360 - rad
    print(rad)
length_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(rad))
print(length_2**0.5)
import math

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


A_kaku = 30*(H)+0.5*(M)
B_kaku = 6*M
kaku = abs(A_kaku - B_kaku)
kaku = min(kaku,180-kaku)
kaku = math.radians(kaku)
X2 = A*A + B*B - 2*A*B*math.cos(kaku)
X2 = math.sqrt(X2)
print(X2)
import math
A, B, H, M = map(int, input().split())

A_rad = (360/12)*H + ((360/12)/60)*M
B_rad = (360/60)*M

if A_rad > B_rad:
    rad_dif = A_rad -B_rad
else:
    rad_dif = B_rad

if rad_dif > 180:
    rad_dif = 360 - rad_dif


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

print('%20.20Lf' %ans)
import math

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


doubledt = 60*H - 11*M
t = 0
if(doubledt > 360):
    t = math.pi * (doubledt-360)/360
else:
    t = math.pi * doubledt/360

tlen = math.sqrt(A*A + B*B - 2*A*B*math.cos(t))
print(tlen)
import math
a,b,h,m=map(int,input().split())
ang=6*m-30*h
if ang<0:
    ang*=-1
ang=ang*math.pi/180
r=math.sqrt(a*a+b*b+2*a*b*math.cos(ang))
print(r)
from math import radians, cos

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

angle_h = (H + M/60) * 30
angle_m = M * 60
theta = min(abs(angle_h-angle_m), 360 - abs(angle_h-angle_m))
r2 = A**2 + B**2 - 2*A*B*cos(radians(theta))
print(r2**(1/2))
import math
A, B, H, M = map(int, input().split())

A_rad = (360/12)*H + ((360/12)/60)*M
B_rad = (360/60)*M

if A_rad > B_rad:
    rad_dif = A_rad -B_rad
else:
    rad_dif = B_rad

if rad_dif > 180:
    rad_dif = 360 - rad_dif


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

print(ans)
import math

A, B, H, M = map(int, input().split())
A_rad = H/12*360 + ((M/60)*(360/12))
B_rad = M/60*360
rad = abs(A_rad - B_rad)
if rad >= 180:
    rad = 360 - rad

cosAB = round(math.cos(math.radians(rad)), 11)
C = ((A**2 + B**2) - 2*A*B*cosAB)**0.5
print(C)
import math
a,b,h,m=map(int,input().split())
tyok=h*30+m*0.5
tank=m*6
sa=0
if tyok==0:
  tyok=360
elif tank==0:
  tank=360

if tyok==tank:
  print(0)
  exit()
elif abs(tyok-tank)==90:
  d=a**2+b**2
  print(math.sqrt(d))
  exit()
elif abs(tyok-tank)>180:
  sa=abs(tyok-tank)-180
else:
  sa=abs(tyok-tank)
  
h=abs(b*math.sin(math.radians(sa)))
ta=h/math.tan(math.radians(sa))
A=a-ta
z=abs(A**2+h**2)
print(math.sqrt(z))
import math
a,b, h, m = map(int, input().split())
rad = math.pi * 2 * ((h/12 + m/60)/12 - m/60)
rs = (a**2 + b**2) - (2*a*b) * math.cos(rad)
print(rs)
import cmath

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

A = param[0]
B = param[1]
h = param[2]
m = param[3]

print(abs(A*pow(cmath.e, (cmath.pi*m/30)*1j) - B*pow(cmath.e, (cmath.pi*h/6)*1j)))
import math

def test(a, b, h, m):
  h_x = a * math.sin((h * math.pi) / 6)
  h_y = a * math.cos((h * math.pi) / 6)
  m_x = b * math.sin((m * math.pi) / 6)
  m_y = b * math.cos((m * math.pi) / 6)
  
  print(math.sqrt(((h_x-m_x) ** 2) + ((h_y-m_y) ** 2)))
  
a, b, h, m = input().split()
test(int(a), int(b), int(h), int(m))
import math

list_input = list(map(int, input().split()))
a = list_input[0]
b = list_input[1]
hour = list_input[2]
minute = list_input[3]

# cos(theta) 計算
hour_angle = 2 * math.pi * (hour / 12)
minute_angle = math.pi / 6 * (minute / 60)
target_angle = abs(hour_angle - minute_angle)

target_length = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(target_angle))
print(target_length)
import math
A, B, H, M = map(int, input().split())
Hno = 30 * H + 30 * M / 360
Mno = 6 * M

if Hno > 180:
    Hno -= 180
if Mno > 180:
    Mno -= 180

angle = Hno - Mno
if angle < 0:
    angle *= -1

cos = math.cos(math.radians(angle))

x = A ** 2 + B ** 2 - (2 * A * B) * cos
print(math.sqrt(x))
import math
a, b, h, m = map(int, input().split())
def ret(hour, minute):
    ans = abs((hour * 30 + minute * 0.5) - (minute * 6))
    return min(360-ans,ans)


print(math.sqrt(a ** 2 + b ** 2 - int(2 * a * b * (math.cos((math.pi * ret(h, m)) / 180.0)))))
import math
a, b, h, m = map(int, input().split())
tha = 30*h*math.pi/180
thb = 5*m*math.pi/180
hx = a*math.cos(tha)
hy = a*math.sin(tha)
mx = b*math.cos(thb)
my = b*math.sin(thb)
ans = math.sqrt((hx-mx)**2 + (hy-my)**2)
print(ans)
import math
A, B, H, M = map(int, input().split())
L_rad = (H + M / 60) * math.pi / 6
S_rad = M / 30 * math.pi
LS_d = max(L_rad, S_rad) - min(L_rad, S_rad)
if LS_d > math.pi:
    LS_d -= math.pi
print(math.sqrt(A**2+B**2-2*A*B*math.cos(LS_d)))
import math

A,B,H,M=map(int,input().split())
N=abs(H*30-M*6)
cos=math.cos(math.radians(N))
L=A**2+B**2-2*A*B*cos
print(math.sqrt(L))
import math

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

MIN = H*30 + M*(1/2) - 6*M

C = A**2 + B**2 - 2*A*B*round(math.cos(math.radians(MIN)),15)

math.sqrt(C)
import math
def readInt():
    return list(map(int, input().split()))
a,b,h,m = readInt()
# print(a)
arg_h = 30*h + 30*(m/60)
arg_m = 6*m
if abs(arg_h-arg_m) <= 180:
    arg = math.radians(abs(arg_h-arg_m))
else:
    arg = math.radians(abs(arg_h-arg_m)-180) 
# print(arg_h, arg_m, arg)
# print(math.cos(arg))
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(arg))
print(ans)
import math
a, b, h, m = map(float, input().split())
hun = h * 60 + m
zisin = hun * 0.5
hunsin = hun * 60 % 360
arg = min(360 - abs(zisin - hunsin), abs(zisin - hunsin))
l = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(arg)))
print(l)
import math
a, b, h, m = map(int, input().split())
m = m / 5
d = abs(h - m) * 30
if d >= 180:
    d -= 180

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

print(c)
A,B,H,M = map(int,input().split())
import math
# 角度を求める
#短針
m = 360/60*M
#長針
h = (360/12*H) + (30/60*M)
#最終角度
kakudo = int(abs(h - m))
kakudo_a = math.radians(kakudo)
cos_x = math.cos(kakudo_a)
 
c = A**2 + B**2 - 2*A*B*cos_x
ans = math.sqrt(c)
print(format(ans,'.21f'))
import math

A,B,H,M = map(int, input().split())
##Aは短針の長さ、Bは長針の長さ
##ARは短針の進んだ針の角度、BRは長針の進んだ針の角度
AR = 360*H/12+30*M/60
BR = 360*M/60

if abs(AR-BR)<180:
  X = abs(AR-BR)
elif abs(AR-BR)>180:
  X = 360-abs(AR-BR)
else :
  X = 0

C = A**2+B**2-abs(2*A*B*math.cos(math.radians(X)))

if X ==0:
  print(A+B)
else:
  print('{:20}'.format(C**0.5))
import math
A, B, H, M = (int(i) for i in input().split())  

hx = math.cos(math.radians(30 * H + (M / 2))) * A
hy = math.sin(math.radians(30 * H + (M / 2))) * A
mx = math.cos(math.radians(6 * M)) * B
my = math.sin(math.radians(6 * M)) * B

print(hx, hy,mx,my)
print(math.sqrt(abs(hx-mx) ** 2 + abs(hy-my) ** 2))
import math

a, b, h, m = map(int, input().split())
h_posi = 30*h + 0.5*m
m_posi = 6*m

kakudo = abs(h_posi - m_posi)
kakudo = min(kakudo, 360-kakudo)
cos = round(math.cos(math.radians(kakudo)), 10)

print((a**2 + b**2 - 2*a*b*cos)**0.5)
import math

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

KA = 360 * (H * 60 + M) // 720
KB = 360 * M // 60
K = 0
if KA >= KB:
    K = KA - KB
else:
    K = KB - KA
if 90 < K < 180:
    K = 180 - K
elif 180 < K < 270:
    K = abs(K)

cc = A ** 2 + B ** 2 - (2 * B * A * math.cos(math.radians(K)))
print(math.sqrt(cc))
A, B, H, M = map(int, input().split())
#A = float(A)
#B = float(B)
#H = float(H)
#M = float(M)

import numpy as np

angle = 2*np.pi*(H-11*M/12)/12
length_squared = A**2 + B**2 - 2*A*B*np.cos(angle)
length = np.sqrt(length_squared)
#print('{:10f}'.format(length))
# 4.56425719433005567605

print(length)
import math
A, B, H, M = map(int, input().split())
alpha = abs(H + M / 60 - M / 5)
if 6 < alpha:
    alpha -= 6

print(math.sqrt(A ** 2 + B ** 2 - (math.cos(alpha * math.pi / 6) * 2 * A * B)))
import math

A, B, H, M = map(int, input().split())
A_rad = H/12*360
B_rad = M/60*360
rad = abs(A_rad - B_rad)
if rad >= 180:
    rad = 360 - rad

cosAB = round(math.cos(math.radians(rad)), 10)
C = (A**2 + B**2 - 2*A*B*cosAB)**0.5
print(C)
import math

a, b, h, m = map(int, input().split())
l = m * 6
s = m * 0.5 + h * 30
th = abs(l - s)
print(th)
if th == 0:
    print('{:.20f}'.format(abs(a - b)))
    exit()
elif th == 180:
    print('{:.20f}'.format(a + b))
    exit()
if th >= 180:
    th = 360 - th
cos = math.cos(math.radians(th))
ans = a**2 + b**2 - 2 * a * b * cos
print('{:.20f}'.format(math.sqrt(ans)))
import math
a, b, h, m = map(int, input().split())
theta_h = math.degrees((h/12)*2*math.pi)
theta_m = math.degrees((m/60)*2*math.pi)
theta = abs(theta_h - theta_m)
print(theta)
if theta > math.degrees(math.pi):
    theta = 2*(math.degrees(math.pi)) - theta
print(theta)
# theta = math.radians(theta)
print((a**2 + b**2 +(-2*a*b*math.cos(math.radians(theta))))**(1/2))
# print(math.sqrt((a**2) + (b**2) - (2*a*b*math.cos(theta))))
import math

a,b,h,m = input().split()
a,b,h,m = int(a),int(b),int(h),int(m)
asin = a * math.sin(math.radians(90-30*h))
acos = a * math.cos(math.radians(90-30*h))
bsin = b * math.sin(math.radians(90-6*m))
bcos = b * math.cos(math.radians(90-6*m))
d = math.sqrt((asin - bsin)**2 + (acos - bcos)**2)
print(d)
import numpy as np
import math

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

d = np.sqrt((B*math.cos(6*M)-A*math.cos(6*H+M/4))**2+\
            (B*math.sin(6*M)-A*math.sin(6*H+M/4))**2)
print(d)
import math

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


doubledt = 60*H - 11*M
t = 0
if(doubledt > 360):
    t = math.pi * (doubledt-360)/360
else:
    t = math.pi * doubledt/360

tlen = math.sqrt(A*A + B*B - 2*A*B*math.cos(t))
print('{:.20f}'.format(tlen))
import math
from decimal import *
a, b, h, m = map(int, input().split())

big = max(30*h, 6*m)
small = min(30*h, 6*m)
gap = min(big - small, 360 - (big - small)) + (m*0.5)


print(format(Decimal(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap)))**Decimal("0.5"), ".20f"))
import math

A, B, H, M = map(int, input().split())
h = H * 30 + M // 2
m = M * 6
sita = min(abs(h - m), 360 - abs(h - m))
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(sita))))
import math
a,b,h,m=map(int,input().split())
if h==0:
  hi=360
else:
  hi=(h*30)
if m==0:
  mi=360
else :
  mi=(m*6)
if h==0 and m==0:
  print('0')
cs=max(hi,mi)-min(hi,mi)
ct=math.cos(math.radians(cs))
bc=(a**2)+(b**2)+(-2*a*b*ct)

ans=math.sqrt(bc)
print("{0:.9f}".format(ans))
import math
A,B,H,M = map(int,input().split())

a=[A*math.cos(math.radians((H+M/60)*360/12)),A*math.sin(math.radians((H+M/60)*360/12))]
b=[B*math.cos(math.radians(M*60)),B*math.sin(math.radians(M*360/60))]
#print(a,b)
dir = ((a[0]-b[0])**2 + (a[1]-b[1])**2)**0.5
print(dir)
import math

a, b, h, m = map(int, input().split())
o = 0
c = (h*30) + (m/60*30)
d = m * 6
if c > d:
    o = c - d
elif c < d:
    o = c + d
if m == 0:
    o = 360 - h*30
print(((a**2)+(b**2)-2*a*b*(math.cos(o/180*math.pi)))**(1/2))
import math
a, b, h, m = map(int, input().split())
ji = 30 * h
hun = 6 * m
dif = abs(ji-hun) + 20
x = a**2 + b**2 - (2*a*b * math.cos(math.radians(dif)))
x = math.sqrt(x)
print(x)
import math

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

rad_a = 2 * math.pi / 12
rad_b = 2 * math.pi / 60

rad_A = rad_a * H
rad_B = rad_b * M
rad = min(abs(rad_A - rad_B), 2*math.pi - abs(rad_A - rad_B))

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

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

H = 360/24*h
M = 360/60*m
if H > M:
  cosA = H-M
elif M > H:
  cosA = M-H
else:
  cosA = 0

A = a**2+b**2-2*a*b*2*(math.cos(math.radians(cosA)))
print(abs(A)**0.5)
import math

a, b, h, m = map(int, input().split())
if m == 0:
    hag = h*(math.pi/6)
else:
    hag = (h-1)*(math.pi/6)
    hag += (m/60)*(math.pi/6)
# print(hag)
mag = m*(math.pi/30)
# print(mag)
diff = abs(hag-mag)
if diff > math.pi:
    diff = math.pi - diff
# print(diff)
val = math.sqrt(a*a + b*b - 2*a*b*math.cos(diff))
print(val)
import math
pi=3.1415926535897932
a,b,h,m=map(int,input().split())
ad=h*30+m*0.5
bd=m*6.0
x=min(abs(ad-bd),360.0-abs(ad-bd))
if abs(x-180.0)<0.0000000001:
    print(a+b)
    exit()
elif abs(ad-bd)<0.000000001:
    print(0)
    exit()
ans=a**2+b**2-(2*a*b*math.cos(math.radians(x)))
print(ans**0.5)
import os
import math

def main():
    a,b,h,m = map(int, input().split())
    rand2 = 6 * m
    rand3 = (0.5 * m) + (30 * h)
    rand_result = 0.0

    if (abs(rand3 - rand2) <= 180):
        rand_result = abs(rand3 - rand2)
    else:
        rand_result = abs(rand3 - rand2) - 180

    ans = math.sqrt(pow(a,2) + pow(b,2) - (2*a*b*math.cos(math.radians(rand_result))))
    print(format(ans,'.10f'))

if __name__ == "__main__":
    main()
from math import sin, pi
A, B, H, M = map(int, input().split())
print( abs( A*sin( pi*(H/6 - M/30) ) ) )
import math
s = input()
S = s.split()

A = int(S[0])
B = int(S[1])
H = int(S[2])
M = int(S[3])

Hang = H*30 + M*0.5
Mang = M*6

if Hang-Mang > 180:
    Difang = 180 - Hang + Mang
else:
    Difang = Hang - Mang

Answ= A**2 + B**2 - 2*A*B*(math.cos(math.radians(abs(Difang))))
ans = math.sqrt(Answ)
print(ans)
import math

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

theta = 2*math.pi*abs(h/12-m/60)
if theta > math.pi:
    theta = 2*math.pi - theta

cos_theta = math.cos(theta)
c = math.sqrt(a**2 + b**2 -2*a*b*cos_theta)
print(c)
from math import cos,pi,sqrt
a,b,h,m=map(int,input().split())
hh = ((h*60 + m)//2)%360
mm = ((h*60 + m)*60)%360
C = (hh-mm+360)%360
d = a*a + b*b -2*a*b*cos((pi*C)/180)
print(sqrt(d))
import numpy as np
a,b,h,m=map(float,input().split())
pi=np.pi
h_deg=(1/6)*pi*h
m_deg=(1/30)*pi*m
deg=abs(m_deg-h_deg)
if(deg>pi):
    deg=2*pi-deg
else:
    pass
c=a**2+b**2-2*a*b*np.cos(deg)
print(c**(1/2))
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b, h, m = map(int, input().split())
    if h * 5 == m:
        print(0)
    elif h * 5 == m * 2:
        print(a + b)
    else:
        h_deg = 360 * (h / 12) + (30 * (m / 60))
        m_deg = 360 * (m / 60)
        deg = h_deg - m_deg if h_deg > m_deg else m_deg - h_deg
        print(math.sqrt(a**2 + b**2 - (2 * a * b * math.cos(math.radians(deg)))))

if __name__ == '__main__':
    main()
a,b,h,m = map(int, input().split())


phi = m * 6

theta = h * 30 + 0.5 * m

import math

apoint = (a*math.cos(math.radians(theta)), a*math.sin(math.radians(theta)))
bpoint = (b*math.cos(math.radians(phi)),   b*math.sin(math.radians(phi)))

print(theta,phi, apoint, bpoint)

xd = abs(apoint[0] - bpoint[0])
yd = abs(apoint[1] - bpoint[1])

print(xd, yd)

ans = math.sqrt(math.pow(xd,2) + math.pow(yd,2))

print(ans)
from decimal import *

import math

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

w_long = 0.5
w_short = 6

minute = H * 60 + M

R_long = minute * w_long
R_short = M * w_short

R = abs(R_long-R_short)

if R == 0 or R == 360:
    print(abs(A-B))
elif R == 180:
    print(A+B)
    
cosR = math.cos(math.radians(R))

ans2 = A**2 + B**2 - 2*A*B*cosR

getcontext().prec = 28     # デフォルト28桁のところを20桁にする
m = Decimal(ans2).sqrt()

print(m)
import math
a,b,h,m=input().split()
a = int(a)
b = int(b)
h = int(h)
m = int(m)
a1 = m*6
a2 = h*30+m/60*30
a3 = abs(a1-a2)
if a3 > 180:
    a3 = a3 - 180
a3 = math.radians(a3)
c = math.cos(a3)
a4 = (a*a+b*b-2*a*b*c)**0.5
print(format(a4,".20f"))
import math
II=input().split()
A = int(II[0])
B = int(II[1])
H = int(II[2])
M = int(II[3])
a=H/12*360
b = M/60*360
# print(a,b)
dist = math.sqrt((A*math.sin(math.radians(a)) - B*math.sin(math.radians(b)))**2 + (A*math.cos(math.radians(a)) - B*math.cos(math.radians(b)))**2)
print(dist)
# print(math.sin(math.radians(a)))
# print(math.sin(math.radians(b)))
# print(math.cos(math.radians(a)))
# print(math.cos(math.radians(b)))
import math
 
A,B,H,M = input().split()
 
A_H = int(H)*30
B_M = int(M)*6
difference=A_H-B_M
if(difference>=180):
  difference=360-difference
a=(int(A)*int(A))
b=(int(B)*int(B))
if (difference<=90):
  ans2 = a + b + (2*int(A)*int(B)*math.cos(difference))
elif(difference>90):
  ans2 = a + b - (2*int(A)*int(B)*math.cos(difference))

ans = math.sqrt(ans2)
print(ans)
import math

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

HH = H * 5

if M > HH:
  M,HH = HH,M
  
angle = (HH - M) * 6 + (M / 60) * 30

if angle > 180:
  angle = angle - 180

if angle == 0:
  print(abs(B - A))
elif angle == 180:
  print(B + A)
else:
  ans = math.sqrt((A ** 2 + B ** 2) - (2 * A * B * (math.cos(math.radians(angle)))))
  
  print(ans,angle)
import math
A,B,H,M = map(int,input().split())

c = abs(H *30 - M * 5.5)
c = c - 180 if c > 180 else c
c = math.radians(c)
d = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(c))
print(d)
import math
a,b,h,m=map(int,input().split())

if 30*h+0.5*m >= 6*m:
    d = 30*h+0.5*m - 6*m
else:
    d= 6*m - 30*h+0.5*m

if h == 0 and m == 0:
    print(0)
    exit()
cos=math.cos(math.radians(d))

print('{:.16f}'.format((a**2+b**2-2*a*b*cos)**0.5))
import math

a,b,h,m=map(int,input().split())
mins=60*h+m
c=(mins*6)
d=mins/2
rads=(((c-d))*math.pi/180)
# print(rads)
dist=math.sqrt(a*a+b*b+2*a*b*math.cos(rads))
print(dist)
import math

def main():
  a, b, h, m = map(int,input().split())
  alpha = 30 * h
  beta = 6 * m
  theta = abs(alpha - beta)
  theta = math.radians(theta)
  squear =  a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)
  ans = math.sqrt(squear)
  print(ans)


if __name__ == '__main__':
  main()
import math
a,b,h,m = map(int,input().split())
x = 6 * m - 15 * h
k = math.cos(math.radians(x))
c = a ** 2 + b ** 2 - 2 * a * b * k
print(math.sqrt(c))
import math
from decimal import Decimal as dec

def main():
    a, b, h, m = map(int, input().split())
    hr = dec(360//12*(h%12)+30*(m%60)//60)
    mr = 360//60*(m%60)
    ans = dec(math.sqrt(a**2+b**2-2*a*b*dec(math.cos(dec(math.radians(abs(hr-mr)))))))
    print(ans)

if __name__ == "__main__":
    main()
import math
a,b, h, m = map(int, input().split())
rad = math.pi * 2 * (h/12 + m/60)/12 - m/60
rs = a**2 + b**2 - 2*a*b * math.cos(rad)
print(rs)
import math
A = list(map(int, input().split()))


L = 30 * A[2] + 0.5 * A[3]
S = 6 * A[3]

print(L,S)


x = A[0]*A[0] + A[1]*A[1] - 2*A[0]*A[1]*math.cos(math.radians(min(math.fabs(L-S)%360,360-math.fabs(L-S)%360)))
print(math.sqrt(x))
import math
a, b, h, m = map(int, input().split())
diff_hm = abs(h*30 - m*6)
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(diff_hm))))
import math
A,B,H,M = map(float, input().split())
rate = M / 60.0
HM = H*5.0 + 10.0*rate
theta = abs(HM-M) * 6.0
if theta > 180:
    theta = 360-theta
#rad = math.radians(theta)
#cos = abs(math.cos(rad))
L = math.sqrt(A**2 + B**2 - 2*A*B*abs(math.cos(math.radians(theta))))
if (HM == M):
    L = 0
print("{:.19f}".format(L))
import math
A,B,H,M = list(map(int,input().split()))
Q = 30*H - 4*M
L = (A**2 + B**2 - 2*A*B*math.cos(math.radians(Q)))**(1/2)
print(L)
import math
n = input().split()

A = int(n[0])
B = int(n[1])
H = int(n[2])
M = int(n[3])

x = abs(H-M)
kakudo = x*30

ans = (A**2) + (B**2) - (2*A*B*(math.cos(math.radians(kakudo))))
ans =math.sqrt(ans)
print(ans)
#C - : (Colon)
import math
A,B,H,M = map(int, input().split())
h = H*30
m = M*6
w = 0
h = h + 0.5*M
w = h - m
if w >= 180:
    w = w-180
#print(h,m,w)
c = A**2+B**2-2*A*B*math.cos(math.radians(w))
print(c**(1/2))
import math

inputLine = input()
tempStr = inputLine.split(' ')

a = int(tempStr[0])
b = int(tempStr[1])
h = int(tempStr[2])
m = int(tempStr[3])

minDeg = 360 * (m / 60)
hourDeg = h * 30 + (30 * (m / 60))

finalValue = hourDeg - minDeg if hourDeg >= minDeg else minDeg - hourDeg
finalValue = 360 - finalValue if finalValue >= 180 else finalValue

if finalValue == 90 :
	print(math.sqrt((a * a) + (b * b)))
elif finalValue == 0 or finalValue == 180 :
	print(b-a if finalValue == 0 else b + a)
else :
	print(math.sqrt((a * a) + (b * b) - (2 * a * b * math.cos(math.pi * (finalValue / 180)))))