peterverebics/CodeNet_Python_118 huggingface dataset:
import math
i = list(map(int,input().split()))
a = i[0]
b = i[1]
h = i[2]
m = i[3]
thete = 6*m - (30*h+m/2)
if thete<0:
    thete = thete*(-1)
if thete > 180:
    thete = 360 - thete
cos = math.cos(math.radians(thete))
ans = math.sqrt(a**2+b**2-2*a*b*cos)
print(ans)
import math
a,b,h,m=map(int,input().split())

rada=(h+m/60)*30
radb=(6*m)
rad=rada-radb
print((a**2+b**2-2*a*b*math.cos(math.radians(rad)))**(1/2))
import math
a,b,h,m=list(map(int, input().split()))


th_a = 360/12 * h + 360/12*m/60
th_b = 360*m/60

ab_th = abs(th_a - th_b)
if ab_th > 180:
    ab_th = 360 - ab_th

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

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

arg=abs(((h*30)+(m*0.5))-m*6)


if arg>180:
    arg=360-arg

rad=math.radians(arg)

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

dim=dim**(1/2)

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

th_h = (h+m/60)/12 *2*math.pi
th_m = m/60 *2*math.pi
c2 = a**2+b**2-2*a*b*math.cos(abs(th_h-th_m) )

print(math.sqrt(c2))
#coding:utf-8
import math

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

sec = H * 3600 + M * 60

arg = abs(math.pi * 11 * sec / (6 * 3600))

arg = min(arg, 2 * math.pi - arg)

cos = math.cos(arg)

x = (A ** 2 + B ** 2 - 2 * A * B * cos) ** 0.5

print("{}".format(x))
import math
a, b, h, m = map(int, input().split())
theta = h / 12 + m / 720 - m / 60
print(math.sqrt(a*a + b*b - 2*a*b*math.cos(theta * 2 * math.pi)))
import math

a,b,h,m=map(int,input().split())
seconds=h*60+m
kaku=seconds*5.5
k_kaku=kaku%360
if k_kaku>180:
  g_kaku=360-k_kaku
else :
  g_kaku=k_kaku
p_kaku=math.radians(g_kaku)
cos=math.cos(p_kaku)
l=a**2+b**2-2*a*b*cos
len=math.sqrt(l)
print(len)
import math
PI = math.pi

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

rad_h = (h/12 + m/60/12) * 2 * PI
rad_m = m/60 * 2 * PI

ans = a**2 + b**2 - 2*a*b*math.cos(rad_h-rad_m)
print(ans**0.5)
A,B,H,M = map(int,input().split(' '))
import math
pi = math.pi
sec = M*60
Ht = pi/6*H + pi/360*M
Mt = M * pi/30
cos = abs(Mt-Ht)
ans = math.sqrt(A*A - 2*A*B*math.cos(cos) + B*B)
print(ans)
import math
a,b,h,m = map(int,input().split())

time = h * 60 + m


angle1 = time * (1/30 - 1/360)%2

angle2 = min(angle1,2 - angle1)

angle3 = math.pi * angle2


d = math.sqrt(a**2 + b**2 -2*a*b*math.cos(angle3))
print(d)
import math
A,B,H,M = map(int, input().split())
kakuc=(((60*H)+M)*(math.pi)/360)-M*(math.pi)/30
C=math.sqrt(A*A+B*B-2*A*B*(math.cos(kakuc)))
print(C)
from math import cos, sqrt
import math

A, B, H, M = map(int, input().split())
Md = M * 6
Hd = (H * 30) + ((M/60) * 30)
Cd = (Hd - Md) * (math.pi/180)
X = sqrt(A**2 + B**2 - (2*B*A * cos(Cd)))
print(X)
import sys
import heapq
import math

def main():
    a, b, h, m = map(int, input().split())
    angle = (math.pi / 30) * m - (m * math.pi / 360 + h * math.pi / 6)
    if angle < 0:
        angle = -angle
    ans = math.sqrt(a * a + b * b - 2 * b * a * math.cos(angle))
    print(ans)
    return

if __name__ == "__main__":
    main()
import math

A,B,H,M=map(int,input().split())
th=abs((2*math.pi*M/60)-((2*math.pi*H/12) + (M/60)*2*math.pi/12))
ans=math.sqrt(A**2 + B**2 -2*A*B*math.cos(th))
print(ans)
import math
A, B, H, M = list(map(int, input().split()))
deg_l = 6 * M
deg_s = 30 * H + 0.5 * M
deg = abs(deg_l - deg_s)
cos = math.cos(math.radians(deg))
ans = math.sqrt((A**2) + (B**2) - (2*A*B*cos))
print(ans)
import numpy as np
if __name__ == "__main__":
    A, B, H, M = map(int, input().split())
    a = 0.5 * (60 * H + M) 
    b = 6 * M 
    #print(a, b)
    a = a * np.pi / 180
    b = b * np.pi / 180
    #print(a, b)
    

    c1 = np.sqrt(A**2 + B**2 - 2 * A * B * np.cos(a-b))
    c2 = np.sqrt(A**2 + B**2 - 2 * A * B * np.cos(b-a))
    print(min(c1, c2))
a, b, h, m = list(map(int,input().split()))
r = min(abs(h*30+m*0.5-m*6), 360-abs(h*30+m*0.5-m*6))
import math
c = (a**2+b**2-2*a*b*math.cos(math.radians(r)))**0.5
print(c)
import math

def output(A,B,ang):
    return (A**2 + B**2 - 2 * A * B * math.cos(ang)) ** (1/2)

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

H_ang = H / 12 * 2 * math.pi + M / 60 * math.pi / 6
M_ang = M / 60 * 2 * math.pi
if abs(H_ang-M_ang) > math.pi:
    ang = math.pi * 2 - abs(H_ang - M_ang)
else:
    ang = abs(H_ang - M_ang)

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

jisin = H*30+M*(1/2)
hunsin = M*6
kakudo = max(jisin - hunsin,hunsin-jisin)
if kakudo >= 180:
    kakudo = 360-kakudo
    

c_nijo = A**2+B**2-2*A*B*(math.cos(math.radians(kakudo)))
c = math.sqrt(c_nijo)
print(c)
from sys import stdin
import math
a=stdin.readline().split()

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

pos1=(30*H)+(M/2)
pos2=(6*M)
AA=abs(pos1-pos2)
if AA>180:
    AA=360-AA

ans=math.sqrt(A*A+B*B-2*A*B*(math.cos(AA*(math.pi)/180)))
print(ans)
import math
a,b,h,m=map(int,input().split())

A=30*h+0.5*m
B=6*m
point=abs(A-B)
C=math.cos(math.radians(min(point,360-point)))

print((a**2+b**2-2*a*b*C)**0.5)
import math
a, b, h, m = map(int, input().split())

hrad, mrad = math.pi * (60 * h + m) / 360, math.pi * m / 30
rad = min(abs(hrad - mrad), 2*math.pi - abs(hrad - mrad))

print((a ** 2 + b ** 2 - 2 * a * b * math.cos(rad))** 0.5)
import math
A, B, H, M = map(int,input().split())

H_Angle = (H * 60 + M) * 0.5
M_Angle = M * 6
difAngle = M_Angle - H_Angle
ans_2 = A**2 + B**2 - 2 * A * B * math.cos(math.radians(difAngle))

print(math.sqrt(ans_2))
import math

a,b,h,m=map(int,input().split())
#m分の分針の角度
mk=m/60*360
mkx=b*math.sin(math.radians(mk))
mky=b*math.cos(math.radians(mk))

#h時m分の時針の角度
hk=h/12*360+m/60*360/12
hkx=a*math.sin(math.radians(hk))
hky=a*math.cos(math.radians(hk))

l=((mkx-hkx)**2+(mky-hky)**2)**0.5
print(l)
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    A, B, H, M = read_ints()
    angle1 = 2*math.pi*(H+M/60)/12
    angle2 = 2*math.pi*M/60
    c = abs(angle1-angle2)
    return math.sqrt(A*A+B*B-2*A*B*math.cos(c))


if __name__ == '__main__':
    print(solve())
import math
a,b,h,m = map(int,input().split())
kakudo = ((h*30) + (0.5*m)) - (6*m)
ans = (a**2 + b**2) - 2*a*b * math.cos(math.radians(abs(kakudo)))
print(math.sqrt(ans))
# coding: utf-8
import sys
from math import sin, cos, radians

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 2点間の距離、x座標とy座標
A, B, H, M = lr()
d1 = radians((30 * H + 30 * M / 60) - 90)
d2 = radians((360 * M / 60) - 90)
x1, y1 = A * cos(d1), A * sin(d1)
x2, y2 = B * cos(d2), B * sin(d2)
dis = ((x1-x2) ** 2 + (y1-y2) ** 2) ** .5
print(dis)
import math
def main():
    a,b, h, m = map(int,input().split())
    l = 360 * (m/60)
    s = 30 * h + 30 * (m/60)
    r = abs(s-l)
    ans = a**2 + b**2 -2*a*b*math.cos(math.radians(r))
    print(ans**0.5)
if __name__=='__main__':
    main()
import math
import numpy
A, B, H, M = map(int,input().split())

#tannsinn
s = 6 * M

#長針の進む角
l = 30 * H + 0.5 * M


theta = max(s,l)-min(s,l)
kakudo = min(360-theta, theta)


ansans = B**2 + A**2 - (2 * B * A * math.cos(math.radians(kakudo)))

ans = math.sqrt(ansans)

print(ans)
import math

a, b, h, m = map(int, input().split())
x = a*(math.cos(math.radians(30*h+0.5*m)))-b*(math.cos(math.radians(6*m)))
y = a*(math.sin(math.radians(30*h+0.5*m)))-b*(math.sin(math.radians(6*m)))
ans = math.sqrt(x**2+y**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)
# -*- coding: utf-8 -*-
import numpy as np

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

rad_H = 2*np.pi*H/12 + 2*np.pi*M/12/60
rad_M = 2*np.pi*M/60


dif = rad_H - rad_M
if (np.abs(dif) > np.pi):
    dif = 2*np.pi - dif


AB = A**2 + B**2 - 2*A*B*np.cos(abs(dif))


print('{:.12f}'.format(np.sqrt(AB)))
import math

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

    x_2 = (a*math.cos(2*math.pi*(h/12 + m/60/12)) - b*math.cos(2*math.pi*m/60)) ** 2
    y_2 = (a*math.sin(2*math.pi*(h/12 + m/60/12)) - b*math.sin(2*math.pi*m/60)) ** 2
    print((x_2 + y_2)**0.5)


main()
import math

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

kakuA = - (List[2] * 60 + List[3]) * 0.5 + 90
kakuB = - List[3] * 6 + 90

xA = List[0] * math.cos(math.radians(kakuA))
yA = List[0] * math.sin(math.radians(kakuA))
xB = List[1] * math.cos(math.radians(kakuB))
yB = List[1] * math.sin(math.radians(kakuB))

d = math.sqrt((xA - xB)**2 + (yA - yB)**2)

print(d)
import math

A,B,H,M=map(int,input().split())
aH=30*H+0.5*M
aM=6*M
r=abs(aH-aM)
a=A*A+B*B-2*A*B*math.cos(math.radians(r))
print(a**0.5)
import math

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

a_angle = math.pi * 2 * (h / 12 + m / (60 * 12))
b_angle = math.pi * 2 * (m / 60)

ans = math.sqrt(pow(a,2) + pow(b,2) - (2 * a * b * math.cos(abs(a_angle - b_angle))))

print(ans)
# ABC168C

from numpy import pi, cos

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

theta = (m / 60 - (h + m / 60) / 12) * 2 * pi

c2 = a**2 + b**2 - 2 * a * b * cos(theta)
print(c2 ** 0.5)
import math
A,B,H,M=map(int,input().split())
H=((H+(M/60))/12)*360; M=(M/60)*360
C=abs(H-M)
C=math.cos(math.radians(C))
print(math.sqrt((A**2)+(B**2)+(-2*A*B*C)))
import math

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

theta=(60*h-11*m)/2
#print(math.cos(math.radians(theta)))

print(math.sqrt(max(0,a*a+b*b-2*a*b*math.cos(math.radians(theta)))))
import math
a,b,h,m = map(int,input().split())
H = 30*h+0.5*m
M = 6*m
if 0<=H<=90:
    H = (90-H)
else:
    H = 450-H
if 0<=M<=90:
    M = (90-M)
else:
    M = 450-M
x_1 = math.cos(math.radians(H))*a
y_1 = math.sin(math.radians(H))*a
x_2 = math.cos(math.radians(M))*b
y_2 = math.sin(math.radians(M))*b
X = abs(x_1-x_2)
Y = abs(y_1-y_2)
dis = math.sqrt(X**2+Y**2)
print(dis)
import math
a,b,h,m=map(int,input().split())
sa=h*30+m/2
sb=6*m
s=max(sa,sb)-min(sa,sb)
if s>180:
  s=360-s
cos=math.cos(math.radians(s))
ans=(a**2+b**2-2*a*b*cos)**(1/2)
print(ans)
import math
a, b, h, m = map(int, input().split()) 


min_sum = 60 * h + m
h_d = math.radians(90 - 360*min_sum/720)
m_d = math.radians(90 - 360*m/60)

h_x = a*math.cos(h_d)
h_y = a*math.sin(h_d)

m_x = b*math.cos(m_d)
m_y = b*math.sin(m_d)

d2 = (h_x-m_x)**2 + (h_y-m_y)**2
ans = d2**0.5
print(ans)
import math


def calc_clock_distance():
    numbers = input().split(' ')

    a = float(numbers[0])
    b = float(numbers[1])
    h = float(numbers[2])
    m = float(numbers[3])

    angle_s = h * math.pi / 6.0 + (m * 2.0 * math.pi / 60.0 / 12.0)
    angle_l = m * math.pi / 30.0

    angle = math.fabs(angle_s - angle_l)

    print(math.sqrt(a * a + b * b - 2.0 * a * b * math.cos(angle)))


if __name__ == '__main__':
    calc_clock_distance()
import math
l1 , l2 ,hour, minute  = map(int,input().split())

minuteAngel = (float(minute)*360)/60
hourAngel = (float(hour)%12)*30 + (float(minute)*30)/60
angel = abs(hourAngel - minuteAngel)

tmp = l1**2 + l2**2 - 2 * l1 * l2 * math.cos(math.radians(angel))

print(math.sqrt(tmp))
from math import cos, sqrt, radians
a, b, h, m = map(int, input().split())
angle = abs(h*30 - m*5.5)
angle = min(angle, 360 - angle)
angle = radians(angle)
c = sqrt(a**2 + b**2 - 2*a*b*cos(angle))
print(c)
import numpy
a, b, h, m = list(map(int, input().split()))

t_angle = (h * 30) + (m * 0.5) # 30 = 360 / 12, 0.5 = 30 / 60
b_angle = m * 6 # 6 = 360 / 60
space_angle = abs(b_angle - t_angle)
c2 = (a * a + b * b) - (2 * a * b * numpy.cos(numpy.radians(space_angle)))
print(numpy.sqrt(c2))
PI = 3.14159265358979323846264338327950

import math
a,b,h,m = map(int,input().split())
# ~units in radians per minute
mw = (PI)/(30)
# ~units in radians per hour
hw = (PI)/(6)

ang = 2*PI*(h/12 + (m/60)/12 - m/60)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(ang))
# ~print(math.degrees(mrd),math.degrees(hrd),math.degrees(ang))
print(c)
import math

#print(math.pi)

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

rad = 2 * math.pi * ((H / 12 + M / (60 * 12)) - M / 60)
ans = math.sqrt(A ** 2 + B ** 2 - (2 * A * B * math.cos(rad)))

print(ans)
import math


def main():
    A, B, H, M = list(map(int, input().split(' ')))
    rad_a = 2 * math.pi * (60 * H + M) / 720
    rad_b = 2 * math.pi * M / 60
    theta = abs(rad_a - rad_b)
    print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(theta)))


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

KakudoA = 2*math.pi*(H+M/60)/12
KakudoB = 2*math.pi*M/60

kakudobetween = min(abs(KakudoA-KakudoB), abs(2*math.pi+KakudoB-KakudoA))

if kakudobetween < 0.00000000000000000001:
	print(abs(B-A))
elif abs(kakudobetween - math.pi) < 0.000000000000000001:
	print(A+B)
else:
	print(math.sqrt(A**2+B**2-2*A*B*math.cos(kakudobetween)))
import math
a,b,h,m = map(int,input().split())

thm = m/60 * 2* math.pi 
thh = (h*60 +  m)/720 * 2* math.pi


xm = b * math.cos(thm)
xh = a * math.cos(thh)

ym = b* math.sin(thm)
yh = a* math.sin(thh)

l=math.sqrt((xm-xh)**2 + (ym-yh)**2)
print(l)
import sys
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, H, M = [int(x) for x in input().split()]

    kakudo1 = M * 6
    kakudo2 = 30 * (H % 12) + M * 0.5

    x = min(abs(kakudo2 - kakudo1), abs(kakudo1 - kakudo2))

    x = min(x, abs(x - 360))


    c = A * A + B * B  - A * B * 2 * math.cos(math.radians(x))
    print(math.sqrt(c))


if __name__ == '__main__':
    main()
import math
a,b,h,m = map(int,input().split())
hour = 30*h+0.5*m
minutes = m*6

Long = max(hour,minutes)
short = min(hour,minutes)

ans = (a**
2+b**2-2*a*b*math.cos(math.radians(Long-short)))**0.5
print(ans)
import math
a,b,h,m = map(int,input().split())
ans_cos = math.cos(math.pi*(60*h-11*m)/360)
ans = math.sqrt(a**2+b**2-2*a*b*ans_cos)
print(ans)
import math
a,b,h,m=map(int,input().split())
q=h*30+m*0.5
w=m*6
cosa=math.cos(math.radians(q-w))
print((a**2+b**2-2*a*b*cosa)**0.5)
A, B, H, M = list(map(float, input().split()))

import math

v_h = (2*math.pi) / (12*60)
v_m = (2*math.pi) / 60

length = math.sqrt(A**2 + B**2 -2*A*B*math.cos(v_h*(H*60+M)-v_m*M))
print(length)
#168
#c
import math
a,b,h,m = list(map(int, input().split()))
oa = (60*h + m)/2
ob = m*6
cos_ab = math.cos(math.radians(oa-ob))
c = abs((a**2 + b**2 -2*a*b*cos_ab)**0.5)
print(c)
import numpy as np
import math 
A, B, H, M = map(int, input().split())

pai = math.pi
angle = 2*pai*((H+M/60)/12 - M/60)

distance = np.sqrt(A**2+B**2-2*A*B*np.cos(angle))
print(distance)
import math

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

angA = (H*60 + M) * (360/(12*60))
angB = M * (360/60)
angle = math.radians(max([angA, angB]) - min([angA, angB]))
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))
print(C)
import math

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

a_speed = 0.5 #degree
b_speed = 6    #degree

a_point = 30*h + a_speed*m
b_point = b_speed*m
if a_point > b_point:
    degree = a_point - b_point
else:
    degree = b_point-a_point
    
degree = min(degree, 360-degree)
feature = (a**2+b**2)-2*b*a*math.cos(math.radians(degree))
print(feature**0.5)
a,b,h,m = map(int,input().split())

import math
x = ((30*h)+30*(m/60))%360
y = (6*m)%360
s = abs(x-y) if abs(x-y) < 180 else 360 - abs(x-y)
#print(s,math.cos(math.radians(s)))

k = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(s)))

print(k)
import math

A, B, H, M = (int(x) for x in input().split())

minuteAngle = math.radians(M * 6)

hourAngle = math.radians(M * 30 / 60 + H * 30)

angleC = abs(hourAngle - minuteAngle)

print(math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * math.cos(angleC))))
import math


def main():
    a, b, h, m = map(int, input().split())
    short = m*360//60
    long = (h*360//12 + (360//12)*(m/60)) % 360
    angle = min(abs(short-long), 360-(abs(short-long)))
    # print(short, long, angle)
    # print(2*a*b*math.cos(angle*math.pi/360))
    ans = (pow(a, 2) + pow(b, 2) - 2*a*b*math.cos(angle*math.pi/180))**(1/2)
    print("{: .13f}".format(ans))
    return


if __name__ == "__main__":
    main()
import math

A,B,H,M=map(int,input().split())
z=H+M/60
n=math.radians(30*z)
m=math.radians(6*M)

X1=A*(math.sin(n))
X2=A*(math.cos(n))
Y1=B*(math.sin(m))
Y2=B*(math.cos(m))

S=((X1-Y1)**2+(X2-Y2)**2)**0.5
print(S)
import math
jishin, hunshin, hour, minute = map(float, input().split())

x_ji = jishin * math.cos(math.radians((hour + minute / 60) * 360 / 12))
y_ji = jishin * math.sin(math.radians((hour + minute / 60) * 360 / 12))
x_hun = hunshin  * math.cos(math.radians(minute * 360 / 60))
y_hun = hunshin  * math.sin(math.radians(minute * 360 / 60))

kyori = math.sqrt((x_ji - x_hun) ** 2 + (y_ji - y_hun) ** 2)
print(kyori)
import math
 
A,B,H,M = map(int,input().split())
angh = H*30+M*0.5
angm = M*6
ang = abs(angh - angm)%360
C = (A**2+B**2-2*A*B*math.cos(math.radians(ang)))**0.5
 
print(C)
from math import cos, sin, radians
from cmath import exp

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

# 時針は一時間あたり360/12 = 30度
# 時針は一分あたり30/60 = 0.5度
# 分針は一分あたり360/60 = 6度
hdeg = radians(h * 30 + m * 0.5)
mdeg = radians(m * 6)

# オイラーの公式
hz = a * exp(complex(0, hdeg))
mz = b * exp(complex(0, mdeg))

# 複素数平面における二点間の距離
dist = abs(hz - mz)

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

import math

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

btheta = M / 60 * 2 * math.pi

theta = abs(atheta - btheta)
if theta >= math.pi:
  theta = 2*math.pi - theta


ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta))
print(ans)
import math
pi = math.pi
A, B, H, M = map(int, input().split())

# thetaの正負が少し気になるが、cosを取るだけなので問題ない
theta = 2 * pi * ((H * 60 + M) / (12 * 60) - M / 60)

# 余弦定理
ans2 = A * A + B * B - 2 * A * B * math.cos(theta)
# 平方根を取るのを忘れずに
ans = math.sqrt(ans2)

print(ans)
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

L = input().split()
A = int(L[0])
B = int(L[1])
H = int(L[2])
M = int(L[3])


rad_A = H * 30 + M * 0.5
rad_B = M * 6

rad = rad_A - rad_B
if rad > 180:
    rad = 360 - rad

cos_num = math.cos(math.radians(rad))


x_squared = A**2 + B**2 - (2 * A * B * cos_num)
ans = math.sqrt(x_squared)

print(ans)
import math

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

    p = math.pi
    alpha = (60 * h + m) * p / 360
    beta = p * m / 30
    theta = alpha - beta

    c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)
    c = math.sqrt(c2)

    print(c)
import math

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

x = abs((h*60 + m) * 5.5)
x = x % 360

ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(x)))**(1/2)

print(ans)
import math
A, B, H, M=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=map(int,input().split())

d=abs(30*h+0.5*m - 6*m)
d=min(d,360-d)

e=math.cos(math.radians(d))

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

PI = math.pi

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

rad = 2 * PI * abs(h / 12.0 + m / 60.0 / 12.0 - m / 60.0)

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

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

x=6*M#長針の角度
y=30*H+(M/60)*30
Q=max(x-y,-(x-y))
W=min(360-Q,Q)

X=(A**2)+(B**2)-2*A*B*(math.cos(math.radians(W)))
print(X**(0.5))
import math

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

m = M * 6
h = H * 30 + M / 2 

ms = B * math.sin(math.radians(m))
mc = B * math.cos(math.radians(m))
hs = A * math.sin(math.radians(h))
hc = A * math.cos(math.radians(h))

ans = ((ms - hs) ** 2 + (mc - hc) ** 2) ** 0.5

print(ans)
import math
import decimal
decimal.getcontext().prec = 11
a,b,h,m = map(int,input().split())
cost = math.cos(math.radians(30*h-5.5*m))
l = decimal.Decimal((a**2+b**2-2*a*b*cost)**(1/2))
print(l)
import math
import sys

def calc_clock_angle(h, m):
    m_angle = (360 / 60) * m
    h_angle = (360 / 12) * h + ((360 / 12) / 60 ) * m
    angle = abs(m_angle - h_angle)
    if angle > 180:
        return 360 - angle
    else:
        return angle
    pass

a, b, h, m = map(int, input().split())
if h == 12 and m == 0:
    print(abs(a - b))
    sys.exit()

angle = calc_clock_angle(h, m)

t = math.sqrt(a**2 + b**2 - (2 * a * b * math.cos(math.radians(angle))))
print(t)
A,B,H,M = map(int,input().split())

import math

H_tmp = 2*math.pi*(H/12) + (2*math.pi/12)*(M/60)
M_tmp = 2*math.pi*(M/60)

kakudo = min(abs(H_tmp-M_tmp),2*math.pi - abs(H_tmp-M_tmp))

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

print(ans)
import numpy as np
A, B, H, M = map(int, input().split())

h_rot = np.pi / 2 - (np.pi * (H * 30 + M / 2) / 180 )
m_rot = np.pi / 2 - np.pi * (6 * M) / 180 

x_diff = (A * np.cos(h_rot) - B * np.cos(m_rot)) ** 2
y_diff = (A * np.sin(h_rot) - B * np.sin(m_rot)) ** 2

print(np.sqrt(x_diff + y_diff))
import math

A,B,H,M = map(int,input().split())
theta1 = (30*H)+(0.5*M)
theta2 = 6*M

theta = min(abs(theta1-theta2),360-abs(theta1-theta2))
X = math.sqrt((A**2)+(B**2)-(2*A*B*math.cos(math.radians(theta))))

print(X)
import numpy as np

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


def calc_rad(base, time):
    try:
        return 2 * np.pi * ((time) % base) / base
    except ZeroDivisionError:
        return 0


rad_a, rad_b = calc_rad(720, 60 * h + m), calc_rad(60, m)
ans = np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(rad_a - rad_b))
print("{:.20f}".format(ans))
import math
A, B, H, M = list(map(int, input().split()))

h = (H%12) / 12 * 360 + .5 * M
m =  M / 60 * 360
radian = math.cos(math.radians(abs(h-m)))
ans = math.sqrt(A**2 + B**2 - 2 * A * B * radian)
print('{:.15f}'.format(ans))
import sys
import math
 
a, b, h, m = map(int, input().split())
 
#if h == 0 and m == 0:
#  print(0)
#  sys.exit()
  
angle_h = (h*60 + m) * (360 / 12 / 60)
angle_m = m * (360 / 60)
 
angle = abs(angle_h - angle_m)
radian = math.radians(angle)
cosine = math.cos(radian)
ans = a*a + b*b - 2*a*b * cosine
ans = math.sqrt(ans)
 
print(ans)
import math
a, b, h, m = map(int, input().split())
time = h + m/60
theta = abs(6*m - 30 * time%360)*math.pi/180
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(theta))
print(ans)
import math

a,b,h,m = map(int, input().split())
huna = m*6
zia = (60*h + m)*0.5
sita = 0.0
if huna >= zia:sita = huna - zia
else:sita = zia - huna

if sita > 90:sita = 360 - sita
ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(sita)))**0.5
print('{:.20f}'.format(ans))
A,B,H,M = map(int,input().split())
import math
pi = math.pi
c = pi*abs(H+M/60-M/5)/6
CC = A**2+B**2-2*A*B*math.cos(c)
print(math.sqrt(CC))
import math
a, b, h, m = map(int, input().split())
kakudo1 = m*6
kakudo2 = h*30 + m*0.5
kakudo = abs(kakudo1-kakudo2)
kakudo = 360 - kakudo if kakudo > 180 else kakudo

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

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

theta1 = 2 * math.pi / 12 * H + 2 * math.pi / 60 / 12 * M  
theta2 = 2 * math.pi / 60 * M

x = math.sqrt(A*A + B*B - 2.0 * A * B* math.cos(theta1 - theta2))

print(x)
from math import pi,cos,sqrt
a,b,h,m=map(int,input().split())
th1=(h/6+m/360)*pi
th2=m*pi/30
th=abs(th1-th2)
th=min(th,360-th)
print(sqrt(a**2+b**2-2*a*b*cos(th)))
import sys
import math

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

j = ((H + ( M / 60 )) / 12) * 360
h = M * 6

z_x_j = math.sin(math.radians(j)) * A
z_y_j = math.cos(math.radians(j)) * A
z_x_h = math.sin(math.radians(h)) * B
z_y_h = math.cos(math.radians(h)) * B

print(math.sqrt((z_x_j - z_x_h) ** 2 + (z_y_j - z_y_h) ** 2 ))
import math
a, b, h, m = map(int, input().split())
if (h==12):
  h= 0
if (m == 60):
  m = 0
hour_angle = 0.5 * (h * 60 + m) 
minute_angle = 6 * m  
angle = abs(hour_angle - minute_angle)  
angle = min(360 - angle, angle)
dis = (a**2 + b**2 - 2*a*b*math.cos(math.radians(angle)))
dis = dis**(0.5)
print("{0:.12f}".format(dis))
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np

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

l_pos = 6 * M
s_pos = 30 * H + 0.5 * M

deg = s_pos - l_pos

sa = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(np.deg2rad(deg)))
print(sa)
import math

a,b,h,m=map(int,input().split())
def c(a,b,h,m):
  theta=abs((h*30+m*0.5)-m*6)
  if theta>180:
        theta=360-theta
  h=a**2+b**2-2*a*b*math.cos(math.radians(theta))
  print(math.sqrt(h))

c(a,b,h,m)