peterverebics/CodeNet_Python_118 huggingface dataset:
from math import sin, cos, pi, sqrt
a, b, h, m = (int(i) for i in input().split())
alpha, beta = 2*pi/12*h + 2*pi/12/60*m, 2*pi/60*m
ax, ay = a*sin(alpha), a*cos(alpha)
bx, by = b*sin(beta), b*cos(beta)
print(sqrt((ax - bx)**2 + (ay - by)**2))
import os

import math
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

A, B, H, M = list(map(int, sys.stdin.buffer.readline().split()))

h = (H / 12 + M / (12 * 60)) * math.pi * 2
m = M / 60 * math.pi * 2

theta = abs(h - m)
if theta > math.pi * 2:
    theta = math.pi * 2 - theta
cc = A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)
ans = math.sqrt(cc)
print(ans)
import math
A,B,H,M=map(int,input().split())

dA=(60*H+M)/2
dB=6*M
rad=dA-dB

C=math.radians(rad)

c=(A**2+B**2-2*A*B*math.cos(C))**0.5
print(format(c,'.10f'))
import math
a, b, h, m = map(int, input().split())
ba = (360 / 60) * m
aa = 30*h +(30/60)*m
ca = aa - ba
if ca >= 180:
    ca1 = 360-ca
else:
    ca1 = ca

d = math.cos(math.radians(ca1))
c = (a**2 + b ** 2 -2*a*b*d)** 0.5
print(c)
import sys
import math
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    A, B, H, M = readnums()
    d = min(0.5 * (H * 60 + M) - 6 * M, 360 - (0.5 * (H * 60 + M) - 6 * M))
    print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(d))))


if __name__ == "__main__":
    main()
import math
a,b,h,m = map(int, input().split())
h_angle = h*30+m*0.5
m_angle = m*6
ang = math.radians(h_angle-m_angle)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(ang)))
from math import pow, cos, radians, sqrt

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

angle_h = 360 * (h / 12) + 30 * (m / 60)
angle_m = 360 * (m / 60)
angle = abs(angle_h - angle_m)
angle = angle if angle <= 180 else 360 - angle

ans = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(radians(angle))
print(sqrt(ans))
import math
def get_theta(H,M):
    M_angle = 6 * M
    H_angle = 30 * H + 0.5 * M
    return (M_angle - H_angle) * math.pi / 180 
def calculate_vector_distance(a,b,theta):
    return math.sqrt(a**2 + b ** 2 - 2*a*b*math.cos(theta))
if __name__ == "__main__":
    A,B,H,M = map(int,input().split())
    print(calculate_vector_distance(A,B,get_theta(H,M)))
import math

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

S=(H/12)*360+(M/60)*(360/12)
L=(M/60)*360
S-L

Lens=A**2+B**2-2*A*B*math.cos((S-L)*math.pi/180)
print(Lens**(1/2))
import numpy as np
A, B, H, M = map(int, input().split())
aH = H / 12.0 * 2 * np.pi + M / (12 * 60) * 2 * np.pi
aM = M / 60.0 * 2 * np.pi
print(np.sqrt(A**2 + B**2 - 2 * A * B * np.cos(np.abs(aH - aM))))
import math
A, B, H, M = map(int,input().split())
x = math.radians(H*30-M*5.5)
print((A**2+B**2-2*A*B*math.cos(x))**0.5)
import math
a,b,h,m = map(int, input().split())
p = (h*60+m)%720/720
q = (h*60+m)%60/60
px,py = a*math.sin(2*math.pi*p),a*math.cos(2*math.pi*p)
qx,qy = b*math.sin(2*math.pi*q),b*math.cos(2*math.pi*q)
#print(p,q,px,py,qx,qy)
print(((qx-px)**2+(qy-py)**2)**0.5)
import numpy as np
A,B,H,M = map(int,input().split())

t = (30*H -5.5*M)/180 * np.pi
print((A**2 +B**2 -2*A*B*np.cos(t))**0.5)
import math
a,b,h,m = map(int, input().split())

ans = 0
a_h = (h+m/60)/12*2*math.pi
a_m = m/60*2*math.pi

print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(abs(a_h-a_m))))
import math
 
A, B, H, M = map(int, input().split())
 
th_h = 360 // 12 * H + 360 / 12 / 60 * M
th_m = 360 // 60 * M
 
ans = A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(abs(th_h - th_m)))
print(math.sqrt(ans))
import math
# スペース区切りの整数の入力
A, B, H, M = map(int, input().split())

Arad = (60.0 * H + M) * 2 * math.pi / (12.0 * 60.0)
Brad = M * math.pi / 30.0


Ax = A * math.cos(-Arad+ math.pi/2)
Ay = A * math.sin(-Arad+math.pi/2)
Bx = B * math.cos(-Brad+math.pi/2)
By = B * math.sin(-Brad+math.pi/2)

print(math.sqrt((Ax - Bx)**2 + (Ay - By)**2))
import math

a, b, h, m = map(int, input().split())
x = h * (360 / 12) + m * (30 / 60)
y = m * (360 / 60)

z = x - y if x >= y else y -x
ans = math.sqrt((a*a) + (b*b) - 2 * a * b * math.cos(math.radians(z)))
print(ans)
from math import radians, cos,sqrt
a,b,h,m = map(int,input().split())
# hour: 1min 0.5  minute: 1min 6
min_total = h*60 + m
rad_h = min_total*0.5 % 360
rad_m = m*6
rad_diff = abs(rad_h - rad_m)
if rad_diff >= 180:
    rad_diff = 360 - rad_diff
#print(rad_diff)
result2 = a**2 + b**2 - 2*a*b*cos(radians(rad_diff))
print(sqrt(result2))
import math
import numpy as np
A, B, H, M = (int(i) for i in input().split())  

angleA = math.pi * 2 * (1 - (H/12 + 1/12 * M/60) + 1/4)
angleB = math.pi * 2 * (1 - M/60 + 1/4)

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

print(np.linalg.norm(a - b))
import math
A, B, H, M = map(int, input().split())
Md = 2*math.pi * 1/60 * M
Hd = 2*math.pi * (1/12 * H + 1/(12*60)*M)

print( ( A**2 + B**2 - 2*A*B*math.cos(abs(Hd-Md)))**(1/2) )
import math
A,B,H,M = map(int, input().split())

# 12時からの角度を求める
# [１分あたりに進む角度]＝３６０÷（１２×６０）
tansin = (H*60+M)*0.5
tyosin = M*6
kakudo = tansin - tyosin
ans = (A**2)+(B**2)-(2*A*B*math.cos(math.radians(kakudo)))
print(math.sqrt(ans))
import math
a, b, h, m = map(int, input().split())
tha, thb = math.pi / 6 * (h + m / 60), m / 30 * math.pi
print((a**2 + b**2 - 2*a*b*math.cos(max(tha, thb) - min(tha, thb)))**0.5)
import math
A,B,H,N= map(int,input().split())
sa=((15-H)%12)*30-N/2
sb=((75-N)%60)*6
c1=math.sin(math.radians(sa))*A
c2=math.cos(math.radians(sa))*A
d1=math.sin(math.radians(sb))*B
d2=math.cos(math.radians(sb))*B
print(((c1-d1)**2+(c2-d2)**2)**(0.5))
import math
A, B, H, M = map(int, input().split())

L = (60 * H + M) / 2
S = M * 6
dig = L - S

#print(dig, L, S)
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(dig))))
import math
 
A, B, H, M = map(int, input().split())
 
m_rad = 360 / 60 * M
h_rad = 360 / 12 * H + (360 / 12 * M / 60)

rad = abs(m_rad - h_rad)

print((A**2 + B**2 - 2 * A * B * math.cos(math.radians(rad))) **(1/2))
import math
A, B, H, M = [int(i) for i in input().split()]
short_hand = ((H * 60 + M) * 0.5) % 360
long_hand = M * 6
theta = abs(short_hand - long_hand)
C = (A**2 + B**2 - 2*A*B*math.cos(theta / 180 * math.pi)) ** 0.5
print(C)
import math

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

deg = 0

deg += 5.5 * m
deg -= 30 * h

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(abs(deg)))))
import math

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

deg_val_hr = h*(math.pi/6)

deg_val_min = 11*m*(math.pi/360)

deg_diff = abs(deg_val_hr - deg_val_min);


ans = a*a + b*b
ans = ans - (2*a*b*math.cos(deg_diff))

print(math.sqrt(ans))
import sys
import math


def sin(x):
    return math.sin(math.radians(x))


def cos(x):
    return math.cos(math.radians(x))


A, B, H, M = map(int, sys.stdin.readline().strip().split())

Ay = A * sin(90 - (360/12 * H + (360/12)/60 * M))
Ax = A * cos(90 - (360/12 * H + (360/12)/60 * M))
By = B * sin(90 - 360/60 * M)
Bx = B * cos(90 - 360/60 * M)

distance = math.sqrt((Ax - Bx) ** 2 + (Ay - By) ** 2)
print(distance)
import math
A, B, H, M = map(int, input().split())

l = 6 * M

s =(H * 60 + M) * 360 / (12 * 60)

abs = abs(l - s)
pi = math.radians(abs)
ans = (A*A + B*B) - (2 * A * B) * math.cos(pi)
print(math.sqrt(ans))
from math import pi, cos, sqrt

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

short = pi * (h * 60 + m) / 360
long = pi * m / 30

print(sqrt(a*a + b*b - 2*a*b*cos(short - long)))
import math
a, b, h, m = map(int, input().split())
rad_long = (h * 60 + m) / (60) * 2 * math.pi
rad_short = (h * 60 + m) / (12 * 60) * 2 * math.pi

x_long, y_long = b * math.cos(rad_long), b * math.sin(rad_long)
x_short, y_short = a * math.cos(rad_short), a * math.sin(rad_short)

dis = ((x_long - x_short)**2 + (y_long - y_short)**2)**0.5
print(dis)
import math
A,B,H,M=map(int,input().split())
l_rad=6.0*M
s_rad=(60*H+M)/720*360
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(abs(l_rad-s_rad)))))
import math

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

X = min(abs(6*M-0.5*(60*H+M)), 360-abs(6*M-0.5*(60*H+M)))
print((A**2+B**2-2*A*B*(math.cos(math.radians(X))))**0.5)
import math

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

# 角度を求める
a_angle = (h/12 + m/(60*12)) *360
b_angle = m/60*360

#print(a_angle)
#print(b_angle)

line = 0

if a_angle > b_angle:
    angle = a_angle - b_angle
elif a_angle < b_angle:
    angle = b_angle - a_angle 
else:
    angle = 0


    
if angle >=180:
    angle = 360-angle

#print(angle)

c2 = pow(a,2) + pow(b,2) - 2 * a * b * math.cos(math.radians(angle))

c = pow(c2, 1/2)
print(c)
import math as ma
a,b,h,m = map(int,input().split())
ans = abs(30 * (h%12) + 0.5 * m  - 6 * m)
if ans > 180:
    ans = abs(360 - ans)
c = ma.cos(ma.radians(ans))
res=(a**2)+(b**2)-((2*a*b)*c)
print(res**0.5)
import math
a, b, h, m = map(int, input().split())
th = (60 * h + m) * math.pi / 360
tm = m * math.pi / 30
dx = a * math.cos(th) - b * math.cos(tm)
dy = a * math.sin(th) - b * math.sin(tm)
print(math.sqrt(dx * dx + dy * dy))
A, B, H, M = map(int,input().split())
import math
minute = H*60 +M

if (math.modf(minute/(180/5.5))[1])%2 ==0:
    theta = 5.5*(minute-math.modf(minute/(180/5.5))[1]*(180/5.5))
else:
    theta = 180 - 5.5*(minute-math.modf(minute/(180/5.5))[1]*(180/5.5))

ans = (A**2 + B**2 - 2*A*B*math.cos(math.radians(theta)))**(1/2)
print(ans)
from math import sqrt, cos, radians

a, b, h, m = map(int, input().split())
mm = h * 60 + m
ag_s = 360 * (mm / (12*60))
ag_l = 360 * (m / 60)
theta = abs(ag_s - ag_l)
ans = sqrt(a**2 + b**2 - 2*a*b * cos(radians(theta)))
print(ans)
import math
L=0
A,B,H,M=map(int,input().split())
theta=(11*M-60*H)*math.pi/360
L=math.sqrt(A**2+B**2-2*A*B*math.cos(theta))
print(L)
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))))
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 math import *
A,B,H,M=map(int,input().split())
j=pi/6j
print(abs(A*e**((H+M/60)*j)-B*e**(M/5*j)))
import math
a,b,h,m = map(int,input().split())

h_ang = 0.5* (h*60+m) #度
m_ang = 6.0 * m

ang = math.fabs(h_ang-m_ang)

if ang > 180:
    ang = 360 - ang


if ang <= 90:
    ans = ((a*math.sin(math.radians(ang)))**2 + (b-a*math.cos(math.radians(ang)))**2)**0.5
else:
    ang = 180-ang
    ans = ((a*math.sin(math.radians(ang)))**2 + (b+a*math.cos(math.radians(ang)))**2)**0.5
print(ans)
import math
A,B,H,M = list(map(int, input().split()))
A = float(A)
B = float(B)
H = float(H)
M = float(M)

t = abs((H/12 + (M/60)/12) - M/60)
print( math.sqrt( A**2 + B**2 - 2*A*B*math.cos(2*math.pi*t) ) )
import math
a, b, h, m = 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)
# -*- coding: utf-8 -*-
import math
from decimal import Decimal
# 入力
a,b,h,m = map(int,input().split())

tri_m = Decimal(360 / 60 * m )

tri_h = Decimal((360 / 12 * h) + (360 / 12 / 60 * m))

# print("tri_m:{},tri_h:{}".format(tri_m,tri_h))
angle = tri_m - tri_h
# if angle > 180:
#   angle -= 180

# print("angle:{}".format(angle))

ans = round(Decimal(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(angle)))),9)

print(str(ans))
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 abs(Hang-Mang) > 180:
    Difang = 360 - abs(Hang - Mang) 
else:
    Difang = abs(Hang - Mang)

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

A, B, H, M = [int(el) for el in input().split()]

minutes = H * 60 + M
h = 360.0 / 60.0 * (minutes % 60)
m = 360.0 / 720.0 * (minutes % 720)
ang = abs(h - m)

print(sqrt(A*A + B*B - 2.0 * A * B * cos(radians(ang))))
import math
A,B,H,M=map(int, input().split())
zikan=0
hun=0
zikan=(M*0.5)+(30*H)
hun=M*6
hari=abs(zikan-hun)
if hari>180:
    hari=360-hari
ans=0
ans_kari=0
ans_kari=A**2+B**2-2*A*B*math.cos(math.radians(hari))
ans=math.sqrt(ans_kari)
print(ans)
import math
A,B,H,M = map(int, input().split())

A_ang = 30*H+30*M/60
B_ang = M*360/60

#print(A_ang, B_ang)
ang = A_ang - B_ang
out = A**2+B**2-2*A*B*math.cos(math.radians(ang))
print(math.sqrt(out))
import math
data = list(map(int, input().split()))

a = data[0]
b = data[1]
h = data[2]
m = data[3]

h = (h+m/60)%12
deg = (h/12-m/60)*2*math.pi
result = math.sqrt(a*a+b*b-2*a*b*math.cos(deg))
print(result)
from math import *

if __name__ == '__main__':
    s = input().rstrip().split(' ')
    A, B, H, M = int(s[0]), int(s[1]), int(s[2]), int(s[3])
    theta = abs(2*pi*(M/60.0) - (2*pi*(H/12.0)+(pi/6.0)*(M/60.0)))
    print(sqrt(A**2 + B**2 - 2*A*B*cos(theta)))
import math
a,b,h,m = map(int,input().split())

h_s = 360*h/12+30*m/60
m_s = 360*m/60
s = abs(h_s - m_s)
print(abs(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(s)))))
from math import sin, cos, pi, sqrt

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

theta1 = 2*pi*((H*60+M)/720)
theta2 = 2*pi*(M/60)

X = [A*cos(pi/2-theta1), A*sin(pi/2-theta1)]
Y = [B*cos(pi/2-theta2), B*sin(pi/2-theta2)]

print(sqrt((X[0]-Y[0])**2 + (X[1]-Y[1])**2))
import math

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


h = h + m /60
h_sin = math.sin(math.radians(h/12*360))
h_cos = math.cos(math.radians(h/12*360))
m_sin = math.sin(math.radians(m/60*360))
m_cos = math.cos(math.radians(m/60*360))

ans = math.sqrt((h_sin*a-m_sin*b)**2+(h_cos*a-m_cos*b)**2)

print(ans)
from math import radians,cos
a,b,h,m=map(int,input().split())
degree=h*30+m*0.5-m*6
degree=min(360-degree,degree)

X=cos(radians(degree))
print((a**2+b**2-2*a*b*X)**0.5)
from math import sqrt,cos,pi

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

# 長針
Ax = A * math.sin(M * math.pi / 30)
Ay = A * math.cos(M * math.pi / 30)

# 短針
Bx = B * math.sin(H * math.pi / 6 + M * math.pi / 360)
By = B * math.cos(H * math.pi / 6 + M * math.pi / 360)

#display(Ax, Ay, Bx, By) ####

ans = math.sqrt((Ax - Bx)**2 + (Ay - By)**2)
print(ans)
a,b,h,m=map(int,input().split())
import math

p=math.pi*m/30 - math.pi*(h+m/60)/6

ans=math.sqrt(a**2+b**2-2*a*b*math.cos(p))
print(ans)
import math
A, B, H, M = map(int, input().split())
k = (60 * H - 11 * M)/2
if abs(k) > 180:
    cos = math.cos(math.radians(360-k))
else:
    cos = math.cos(math.radians(k))

a2 = A**2 + B**2 - 2* A* B* cos

print(a2**0.5)
import math
a, b, h, m = map(int, input().split())
t_a = 0.5*(h*60+m)
t_b = 6*m
t = (t_a - t_b)
if t > 180:
    t = 360 - t
c = math.cos(t*2*math.pi/360.0)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * c), end="")
import math
a,b,h,m = map(int, input().split())
A = (a*math.sin(math.radians(h*30+m/2)),a*math.cos(math.radians(h*30+m/2)))
B = (b*math.sin(math.radians(m*6)),b*math.cos(math.radians(m*6)))
print(((A[0]-B[0])**2+(A[1]-B[1])**2)**0.5)
import math
a, b, h, m = map(int, input().split())

theta = h * 30 - m * 5.5
result = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(theta))
print(result ** (1 / 2))
import math

n=tuple(map(int,input().split()))

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

A_rad=H*math.pi/6+M*math.pi/360
B_rad=M*math.pi/30


A_pos=[A*math.cos(A_rad),A*math.sin(A_rad)]
B_pos=[B*math.cos(B_rad),B*math.sin(B_rad)]

print(math.sqrt((A_pos[0]-B_pos[0])**2+(A_pos[1]-B_pos[1])**2))
import math

a, b, h, m = map(int, input().split())
a_deg = h * 30 + m * 0.5
b_deg = m * 6
deg = abs(a_deg - b_deg) if abs(a_deg - b_deg) <= 180 else 360 - abs(a_deg - b_deg)
# print(f'{deg=}')
dis_sqrt = a**2 + b**2 - 2 * a * b * math.cos(math.radians(deg))
ans = math.sqrt(dis_sqrt)
print(ans)
import math
from math import sqrt
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
from copy import deepcopy

INF=10**18
MOD=10**9+7
MAX=10**5+7


# N,K=map(int, input().split())
# A=list(map(int, input().split()))
if __name__=='__main__':
  a,b,h,m=map(int, input().split())

  s=h*30+30*m/60
  t=360*m/60

  th=min(abs(s-t), 360-abs(s-t))
  c=sqrt(a**2+b**2-2*a*b*math.cos(math.radians(th)))
  print(c)
def main():
    import sys
    import math
    a, b, h, m = tuple(map(int, sys.stdin.readline().split()))
    
    C = math.radians(abs(360*h/12 + 30*m/60 - 360*m/60))
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(C)))

if __name__ == "__main__":
    main()
import math
A,B,H,M = map(int,input().split())

L_S =  H*30 + M/2 - 6*M

L_S = abs(L_S)
if L_S > 180 :
       L_S = 360 - L_S

print(math.sqrt(A**2+B**2 - 2*A*B*math.cos( L_S/180 * math.pi)))
import sys
input = sys.stdin.readline
from collections import *
from math import *

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

if 60*H+M>=12*M:
    rad = 30*H+M/2-6*M
else:
    rad = 6*M-(30*H+M/2)

C = cos(radians(rad))
ans = A**2+B**2-2*A*B*C

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

theta_m = 6*m
theta_h = 30*h+m/2
theta = abs(theta_h-theta_m)
r = math.radians(theta)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(r))
print(ans)
import math
a, b, h, m = list(map(int, input().split()))

h = h + m / 60

theta = min(abs(h/6 - m/30)*math.pi, 2*math.pi - abs(h/6 - m/30)*math.pi)
s = math.sqrt(a**2+b**2-2*a*b*math.cos(theta))

print(s)
from math import pi, sqrt, cos

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

minutes = h * 60 + m

short_angle = pi * minutes / 360
long_angle = pi * m / 30
angle = abs(short_angle - long_angle)
if angle > pi:
    angle = 2 * pi - angle

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

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

rad_h = (h + m / 60) / 12
rad_m = m / 60
# print(rad_h, rad_m)

if rad_h >= rad_m:
	rad = rad_h - rad_m
else:
	rad = rad_m - rad_h
if rad >= 0.5:
	rad = 1 - rad
rad *= math.pi * 2

# print(rad)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)))
import math

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

angle = abs(M*6-(H*30+M*0.5))
if angle > 180: angle=360-angle

angle_2 = math.radians(angle)

C = A**2 + B**2 -2*A*B*math.cos(angle_2)
C = C**0.5
print(C)
import math
n=input()
n=n.split()
for i in range(0,len(n)):
        n[i]=int(n[i])
angle = abs(n[2]+n[3]/60 - n[3]/5)*30
if(angle > 180):
    angle=360 - angle
angle=math.pi*angle/180.00000
c=(n[0]**2) + (n[1]**2)- (2*n[0]*n[1]*math.cos(angle))
print(float(math.sqrt(c)))
import numpy as np
a,b,h,m = map(int,input().split())

t1 = 2 * np.pi * m /60

t2 = 2 * np.pi * ( 60*h+m)/(60*12)

print(np.sqrt(a**2 + b**2 - 2*a*b*np.cos(t2-t1)))
import math

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

sh=math.pi*(H+M/60)/6
sm=math.pi*M/30

s=abs(sh-sm)

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

print(C)
# C - : (Colon)
from math import cos, radians, sqrt


def main():
    A, B, H, M = map(int, input().split())
    rad = abs(H * 30 - M * 5.5)
    ans = sqrt(A ** 2 + B ** 2 - 2 * A * B * cos(radians(rad)))
    print(ans)


if __name__ == "__main__":
    main()
import math
A,B,H,M=map(int,input().split())
deg_m = M*6
deg_h = M/2+30*H
deg = abs(deg_m-deg_h)
print(math.sqrt(A**2+B**2-2*A*B*math.cos(deg*math.pi/180)))
import math
a,b,h,m = map(int,input().split())
h %= 12
h *= 60
h = h + m
ma = m * 6
ha = h * 0.5
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(min(ma-ha,ha-ma)))))
import math
a, b, h, m = map(int, input().split())
h += m/60
dif = abs(h - m/5)
theta = dif / 6 * math.pi
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(theta))
print(ans)
from math import sin, cos, pi


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

    a_theta = (60 * h + m) * pi / 360
    b_theta = (60 * h + m) * pi / 30

    a_x = a * sin(a_theta)
    a_y = a * cos(a_theta)
    b_x = b * sin(b_theta)
    b_y = b * cos(b_theta)

    ans = ((a_x - b_x) ** 2 + (a_y - b_y) ** 2) ** 0.5

    print(ans)


if __name__ == "__main__":
    main()
import math
A,B,H,M=input().split()

  #長針:M*PI/30
  #短針:H*PI/6+M*PI/360
  #a^2=b^2+c^2-2bc*cos(arg)
a=int(A)
b=int(B)
h=int(H)
m=int(M)

Pi=math.pi
radi=abs(m*Pi/30-(h*Pi/6+m*Pi/360))
ans1=math.pow(a,2)+math.pow(b,2)-2*a*b*(math.cos(radi))
ans2=math.sqrt(ans1)
print('{:.10f}'.format(ans2))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math
import cmath

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

def rate_to_arg(rate):
    return - 2 * math.pi * rate

short_rate = (H * 60 + M) / 720
long_rate = M / 60

short = 0 + A * 1j
short *= cmath.rect(1.0, rate_to_arg(short_rate))

long = 0 + B * 1j
long *= cmath.rect(1.0, rate_to_arg(long_rate))

print("{:.20f}".format(abs(long - short)))
import math

A, B, H, M = map(int, input().split())
Mth = 6*M
Hth = 30*H + M/2
th = math.pi*abs(Mth-Hth)/180

x = A**2+B**2-2*A*B*math.cos(th)
result = math.sqrt(x)
print(result)
import math
a, b, h, m = map(int, input().split())
a_d = (60*h + m)/2
b_d = 6*m
degree = abs(a_d - b_d)
cos = math.cos(math.radians(degree))
c_2 = a**2 + b**2 -2*a*b*cos
c = (math.sqrt(c_2))
print(c)
import math
p = math.pi
A,B,H,M = map(int,input().split())
thita1 = 2*p*H/12+2*p/12*M/60
thita2 = 2*p*M/60
sin1 = math.sin(thita1)
sin2 = math.sin(thita2)
cos1 = math.cos(thita1)
cos2 = math.cos(thita2)
l2 = (A*sin1-B*sin2)**2+(A*cos1-B*cos2)**2
l = math.sqrt(l2)
print(l)
import math
A, B, H, M = (int(x) for x in input().split())
theta = abs(6 * ((H*60 + M)/12 - M))
if theta > 180:
    theta = 360 - theta
x = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta)))
print(x)
import numpy as np

def main():
    A, B, H, M = map(float, input().split())
    # 偏角をどう計算するか,0を基準にどれくらい動いてるか
    omega_short = 6*M # 短針を動かす角度(not radian)
    omega_long = 0.5*M+30*H
    diff_rad = np.abs(omega_long - omega_short)
    cos_theta = np.cos(np.deg2rad(diff_rad))
    res = (A**2 + B**2 - 2*A*B*cos_theta)**(1/2)# 余弦定理
    print(res)
if __name__ == "__main__":
    main()
import sys
import math

A,B,H,M = map(int, sys.stdin.readline().strip().split())

# A,B,H,M = [3,4,9,0]
# A,B,H,M = [3,4,10,40]

c = abs((H * 30 + M * 0.5) - (M * 6))
if c > 180:
    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())

deg=abs(2*math.pi*(H/12+M/12/60)-(2*math.pi*M/60))

deg=deg if deg<=math.pi else (2*math.pi-deg)

l=math.sqrt(A**2+B**2-2*A*B*math.cos(deg))

if deg==0:
    print(abs(A-B))
elif deg==math.pi:
    print(abs(A+B))
else:
    print(l)
A,B,H,M = list(map(int,input().split()))

import math

l = H*360/12 + M*30/60
s = M*360/60
ang = abs(l-s)
c = A**2 + B**2 -2*B*A*math.cos(math.radians(ang))
print(math.sqrt(c))
from sys import stdin
import sys, math

a, b, h, m = [int(x) for x in stdin.readline().rstrip().split()]

x = 30*h + 0.5*m
y = 6*m

z = abs(x-y)
if z > 180: z = 360 - z

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

print(c)
#C
from math import cos,pi,pow
A,B,H,M=map(float,input().split())
 
A_d=pi*(H*60+M)/360
B_d=pi*M/30
D=abs(A_d-B_d)
 
result=pow(A**2+B**2-2*A*B*cos(D),0.5)
print(result)
import math
A,B,H,M = [int(i) for i in input().split()]
angle_A = 30*H + M/2
angle_B = 6*M
angle = angle_A - angle_B
C = A**2 + B**2 - 2*A*B*math.cos(math.radians(angle))
print(math.sqrt(C))
def c_colon_dist():
    from math import pi, sin, cos, dist
    A, B, H, M = [int(i) for i in input().split()]

    hour_hand_rad = (60 * H + M) * pi / 360
    minute_hand_rad = M * pi / 30
    hour_hand_pos = (sin(hour_hand_rad) * A, cos(hour_hand_rad) * A)
    minute_hand_pos = (sin(minute_hand_rad) * B, cos(minute_hand_rad) * B)
    return dist(hour_hand_pos, minute_hand_pos)

print(c_colon_dist())
from cmath import*
a,b,h,m=map(int,input().split())
print(abs(rect(a,(h+m/60)*11*pi/6)-b))
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)
if d == 0:
  print(abs(A-B))
else:
  print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(d))))