peterverebics/CodeNet_Python_118 huggingface dataset:
A,B,H,M=map(int,input().split())
import math
print(type(B))
x=A*A+B*B
y=-2*A*B*(math.cos(math.radians(abs(0.5*(60*H+M)-6*M))))
print(math.sqrt(float(x)+y))
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 -= 180
c = math.cos(t*2*math.pi/360.0)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * c), end="")
import math

pi = math.acos(-1)

a, b, h, m = (int(x) for x in input().split())

s_ang = h * 30 + m * 0.5
l_ang = m * 6

ang = abs(s_ang - l_ang)

if ang > 180:
    ang -= 180

rad = pi*ang / 180

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

if ang == 0:
    c = abs(a-b)
elif ang == 180:
    c = a+b
    
print('{:.10f}'.format(c))
import math

A, B, H, M = list(map(int, input().split()))
thita = math.radians(6*M - 30*H)

ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(thita))
print(ans)
import math
a, b, h, m = list(map(int, input().split()))
# 角度を求める
a_angle = 360*h/12 + 360*m/(12*60)
b_angle = 360*m/60
angle=0
if a_angle == b_angle:
    print(abs(a-b))
    exit()
elif a_angle > b_angle:
    angle = a_angle - b_angle
else: 
    angle = b_angle - a_angle

if angle > 180:
    angle = angle - 180
result = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle)))
print(result)
import math
A,B,H,M = map(int, input().split())
# 360 / 12
h_angle = 360/12 * H
# 360 / 60
m_angle = 360/60 * M

tri_angle = abs(h_angle - m_angle)

C = math.sqrt(A**2 + B**2 - (2 * A * B * math.cos(tri_angle)))
print(C)
import sys
import numpy as np


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, h, m = _ia()
    ad = (60*h + m) % 720
    bd = (120 * m) % 720
    dd = abs(ad-bd) % 720
    a, b, d = map(np.float64, [a, b, min(dd, 720-dd)])
    return np.sqrt(a**2 + b**2 - 2*a*b*np.cos(np.deg2rad(d/np.float64(2))))


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

import math

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

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

A = list(map(int,input().split()))
a = A[0]
b = A[1]
h = A[2]
m = A[3]

c = (m / 60 - h) / 6 * math.pi

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

s = abs(30 * h - 6 * m)
sita = math.radians(s)

c = math.sqrt(a ** 2 + b ** 2 - (2 * a * b * abs(math.cos(sita))))

print(c)
import math

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

ang1 = (h%12+m/60) * 30
ang2 = m * 6
ang = abs(ang1-ang2) % 180
if ang > 180:
    ang = 360 - ang

print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang))))
import math
A, B, H, M = map(int, input().split())
deg = abs(H * 30 - M * 6)
print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(deg))))
import math
a,b,h,m = map(int,input().split())
c2= a**2+b**2-2*a*b*math.cos(math.radians(30*h-6*m))
print(30*h-6*m)
print(math.sqrt(c2))
import math

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

m_angle = m / 60 * 360
print(m_angle)
h_angle = (h / 12 * 360) + (m / 60 * 30)
print(h_angle)

theta = abs(m_angle - h_angle) % 180
print(theta)

x2 = a**2 + b**2 - 2*a*b * math.cos(math.radians(theta))
x = x2**0.5

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

import math
theta = m / 12 * 2 * math.pi
theta2 = (h / 12 + m / 12 / 12) * 2 * math.pi

sa = abs(theta - theta2)

if sa >= math.pi:
    sa = 2 * math.pi - sa

ans = math.sqrt(a**2 + b**2 - 2*b*a*math.cos(sa))
print(ans)
import math

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

# 中央角を計算
minutes = (H * 60) + M
short_hand_angle = 0.5 * minutes
long_hand_angle = 6 * M

diff_angle = abs(short_hand_angle - long_hand_angle)
if diff_angle > 180 :
    diff_angle = diff_angle - 180

# 余弦定理
if diff_angle == 90:
    c = A**2 + B**2
elif diff_angle < 90:
    c = A**2 + B**2 - 2*A*B*math.cos(math.radians(diff_angle))
else :
    c = A**2 + B**2 + 2*A*B*math.cos(math.radians(diff_angle))

c = math.sqrt(c)

print(c)
import math
a,b,h,m=map(int,input().split())
total_m=60*h+m

angle_b=360*m/60
angle_a=360*(total_m/(12*60))
print(angle_a,angle_b)

angle=min(abs(angle_a-angle_b),360-abs(angle_a-angle_b))
print(angle)
cosθ=math.cos(math.radians(angle))

c=(a**2+b**2-2*a*b*cosθ)
c=c**(1/2)
print(c)
import math
from decimal import *
a, b, h, m = map(int,input().split())

a_s = ((30 * h) + 0.5 * m) % 360
b_s = (6*m)%360

s = max(a_s,b_s) - min(a_s,b_s)
if s >= 180:
    s -= 180
if s == 0:
    print(abs(a-b))
    quit()
a = Decimal(a)
b = Decimal(b)
t = Decimal(2)
ans = math.sqrt(a**t+b**t-t*a*b*Decimal(math.cos(math.radians(s))))
print(ans)
import math

Line = [float(s) for s in input().split()]

A,B,H,M = Line[0],Line[1],Line[2],Line[3]

# print(A,B,H,M)

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

if kakudo >= 180 :
    kakudo -= 180

print(kakudo)

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

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

x=0

HOUR = H*30
MINUTES=M*6

kakudo = min(abs(HOUR-MINUTES),360-abs(HOUR-MINUTES))
kakudi = math.radians(kakudo)

x=math.sqrt((A**2)+(B**2)-((2*A*B)*(math.cos(kakudi))))

print(x)
import math
def main():
  a, b, h, m = map(int, input().split())
  rad = abs(360 - h * 30 - m * 6)
  rad = math.radians(rad)
  ans = math.sqrt((a ** 2) + (b ** 2) - 2 *a*b*math.cos(rad))
  print(ans)

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

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

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

diff = H - M

if diff < 0:
    if diff <= -180:
        diff = abs(diff + 180)
    else:
        diff = abs(diff)

if diff > 180:
    diff = 180 - (diff - 180)
print(math.sqrt(A**2 + B**2 - (2 * A * B * math.cos(math.radians(diff)))))
import math
from decimal import *
if __name__ == '__main__':
    A,B,H,M=map(int, input().split())
    pi=math.pi
    S1=H/12*360+M/2
    S2=M/60*360
    jiaodu1=math.radians(S1)
    jiaodu2=math.radians(S2)
    jiaodu=abs(jiaodu1-jiaodu2)
    cos=abs(math.cos(jiaodu))
    distance=math.sqrt(A*A+B*B-2*A*B*cos)
    print(Decimal(distance).quantize(Decimal('0.00000000000000000000')))
import math

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

H *= 30
H += 0.5 * M
M *= 6
if (H == M):
    print(0)
else:
    p, q = max(H, M), min(H, M)
    r = min(p-q, (360-p)+q)
    c = round(math.radians(r), 40)
    l = A ** 2 + B ** 2 - 2 * A * B * math.cos(c)
    print(math.sqrt(l))
import math
def main():
    a,b,h,m = map(int, input().split())
    if h == 0: h=12

    ar = h * 360 / 12 + m * 360 / 12 / 60
    br = m * 360 / 60
    kakudo = x if (x := abs(ar+br)) < 180 else 360-x
    print(kakudo)
    ans = a**2 + b**2 - 2 * a * b * math.cos(kakudo * math.pi /360)
    print(math.sqrt(ans))
if __name__ == "__main__":
    main()
import math
a, b, h, m = map(int, input().split())
l_rad = m / 60 * 360
s_rad = h * 30 + m / 60 * 30
c_rad = abs(l_rad - s_rad) if abs(l_rad - s_rad) <= 180 else 360 - abs(l_rad - s_rad)
cos_c = math.cos(math.radians(c_rad))
if cos_c == 1:
    print(0)
elif cos_c == -1:
    print(a + b)
else:
    print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos_c))
import math
A,B,H,M = map(float, input().split())
rate = M / 60.0
HM = H*5.0
theta = abs(HM-M) * 6.0 + 30.0*rate
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 H==0 and M ==0:
  L = 0
print("{:.19f}".format(L))
import math as m
A,B,H,M=map(int,input().split())
a=(30*H)+(M/2)
b=M*1
if b>=a:
    c=b-a
    d=m.radians(c)
    f=m.cos(d)
    e=A*A+B*B-2*A*B*f
    g=m.sqrt(e)
    print(g)
else:
    c=a-b
    d=m.radians(c)
    f=m.cos(d)
    e=A*A+B*B-2*A*B*f
    g=m.sqrt(e)
    print(g)
import math

a, b, h, m = map(int, input().split())
angle = 30*h - 6*m
if(angle >= 180):
  angle = 360 - angle
print(a**2+b**2-(2*a*b*math.cos(math.radians(angle))))
import math

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

H_ang = (H*60 + M)*0.5
M_ang = M*6
ang = M_ang - H_ang
if ang >= 180:
    ang = 360 - ang

if ang >= 90:
    ans = A**2 + B**2 + 2*A*B*math.cos(math.radians(ang))
else:
    ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(ang))

print(math.sqrt(ans))
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math

a,b,h,m=nm()

dh = h/12*360
dm = m/12*360

theta = abs(dh-dm)
if theta >= 180:
  theta = 360-theta

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

print(math.sqrt(ans))
import math
a,b, h, m = map(float, input().split())
rad = math.pi * 2 * ((h/12 + m/60)/12 - (m/60))
rs = float(a*a + b*b) - float(2*a*b) * math.cos(rad)
print(rs)
import math

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

a_kakudo=30*h
b_kakudo=6*m


if a_kakudo>180:
  a_kakudo-=180
if b_kakudo>180:
  b_kakudo-=180

kakudo=abs(a_kakudo-b_kakudo)


if kakudo==180:
  print(a+b)
  exit()
if kakudo<180:
  x=a**2 + b**2 -2*a*b*math.cos(math.radians(kakudo))
  print(x**0.5)
import math
a, b, h, m = map(int,input().split())

a_s = (30 * h) % 360 + 0.5 * m
b_s = (6*m)

s = max(a_s,b_s) - min(a_s,b_s)
if s > 180:
    s -= 180
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)
A,B,H,M = list(map(int,input().split()))

import math
#得られる三角形の中心の角度を求める

H_rad = 2*math.pi/12*H
M_rad = 2*math.pi/60*M
rad = abs(H_rad - M_rad)

#二項定理
C = math.sqrt(abs(A**2 + B**2 - 2*A*B*math.cos(rad)))
print(C)
import math

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

v1 = math.pi/360
v2 = math.pi/3
t = 60 * float(H) + float(M)

u1 = (math.pi/2 - (float(v1) * float(t)))
u2 = (math.pi/2 - (float(v2) * float(t)))

xa = float(A) * math.cos(u1)
ya = float(A) * math.sin(u1)

xb = float(B) * math.cos(u2)
yb = float(B) * math.sin(u2)

d = math.sqrt((xa-xb)**2 + (ya-yb)**2)

print(d)
import math
A,B,H,M = map(int,input().split())
print(math.sqrt(A**2 + B**2 - 2*A*B*abs(math.cos((H/12.+M/720.)*2*math.pi - M/60.*2*math.pi))))
import math

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


a_h = h*30 + m*0.5
a_m = m* 6
print(a_h, a_m)
angle = abs(a_h-a_m)%180

print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle))))
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)
if kaku > 180:
    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 collections
from collections import defaultdict
import math
import numpy as np
import re
import itertools
import bisect

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

l = 6*m
s = 0.5*m+30*h

kakudo = min(abs(l-s),360-abs(l-s))
print(kakudo)
print(math.sqrt(a*a+b*b-2*b*a*math.cos(math.radians(kakudo))))
import math
import decimal

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

l = 6*m
s = 30*h + 0.5*m
r = abs(l-s)
print(r)
cos = math.cos(math.radians(r))
ans = ((a**2+b**2)-2*a*b*cos)**0.5

print('{:.20f}'.format(ans))
import math

s = input()
[a, b, h, m] = s.split()

a = float(a)
b = float(b)
h = float(h)
m = float(m)

hkaku = 360 * ((h + m / 60) / 12)
mkaku = 360 * (m / 60)

minkaku = min(hkaku, mkaku)
maxkaku = max(hkaku, mkaku)
t = maxkaku - minkaku
rad = t * (math.pi / 180)

if t == 90 or t == 270:
    res = math.sqrt(a * a + b * b)
elif t == 0 or t == 180:
    res = math.sqrt(a * a + b * b - 2 * a * b)
else:
    res = math.sqrt(a * a + b * b - 2 * a * b * math.cos(rad))

print(res)
import math
A, B, H, M = map(int, input().split())
tyousin = float(6 * M)
tansin = float(30 * H + 0.5 * M)
kaku = max(tyousin, tansin) - min(tansin, tyousin)
if kaku > 180:
    kaku -= 180
ans = math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * math.cos(math.radians(kaku))))
print(ans)
#C
import math
a, b, h, m = map(int, input().split())

def yo(a, b, c):
    #辺a,b 角c
    # print(pow(a, 2), pow(b, 2), 2 * a * b * math.cos(c))
    tmp = pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(c)
    return pow(tmp, 0.5)
ss = (h / 12 + m / 120) * 2 * math.pi
ls = m / 60 * 2 * math.pi
# print(ss, ls, min(abs(ls - ss), 2*math.pi - abs(ls - ss)))
ans = yo(a, b, min(abs(ls - ss), 2*math.pi - abs(ls - ss)))
print(ans)
import math
A, B, H, M = map(int, input().split())

while M >= 60:
    M -= 60
if H >= 12:
    H -= 12

time = H*60 +M

cho = 6*M
tan = 0.5*time

if cho > tan:
    kakudo = cho - tan
else:
    kakudo = tan - cho

if kakudo > 180:
    kakudo -= 180

k = math.cos(kakudo)

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

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

import math

s = 30*H
t = 6*M

r = abs(s-t)

if r>180:
  r = 360-r

a = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(r)))

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

kakua = 30 * h + 0.5 * m
kakub = 6 * m
soutai = (kakua - kakub) % 180
#print(soutai)
print(abs(a ** 2 + b ** 2 - 2*a*b*(math.cos(math.pi/180*soutai)))**(1/2))
import math
A = list(map(int, input().split()))
#0=A 1=B 2=H 3=M
Ax = A[0] * math.cos(math.radians(90-A[2]*30))
Ay = A[0] * math.sin(math.radians(90-A[2]*30))
Bx = A[1] * math.cos(math.radians(90-A[3]*6))
By = A[1] * math.sin(math.radians(90-A[3]*6))
ll = (Ax-Bx)**2 +(Ay-By)**2 
print(math.sqrt(ll))
from math import *

A, B, H, M = [float(i) for i in input().split()]

y1 = sin(-H/6*pi+0.5*pi-M/60/6*pi)*A
x1 = cos(-H/6*pi+0.5*pi-M/60/6*pi)*A
x2 = cos(-M/30*pi+0.5*pi)*B
y2 = sin(-M/30*pi+0.5*pi)*B
print(x1,y1,x2,y2)
print(sqrt((x2-x1)**2+(y2-y1)**2))
import math

a, b, h, m = map(int, input().split())
a_h = h*30 + m*0.5
a_m = m* 6
angle = abs(a_h-a_m)%180

print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle))))
import math
A, B, H, M = map(int, input().split())
h = (H / 12 + M / 720)
m = M / 60
rad = (abs(h-m) * 360) % 180
print((A**2 + B**2 - 2 * A * B *  math.cos( math.radians(rad) ) )** 0.5 )
import math


def distance():
    a, b, h, m = map(float, input().split())
    degree = abs(h*math.pi/6-m*math.pi/30)

    dis = math.sqrt(a*a+b*b-2*a*b*math.cos(degree))
    print(dis)


distance()
import math as m
A, B, H, M = list(map(int, input().split()))
print(m.sqrt(A**2+B**2-2*A*B*m.cos(3.14159265/180*(30*H-11*M/2))))
import math

a, b, h, m = map(int, input().split())
kaku =((h*60+m)*360/(12*60))-(6*m)
if kaku >= 180:
  kaku = kaku-180
#print(kaku)
ans = (a**2) + (b**2) -(2*a*b*(math.cos(math.radians(kaku))))
#ans = math.cos(math.radians(90))#-2(a*b)*(math.cos(math.radians(kaku)))#(a**2) + (b**2) #-2(a*b)*(math.cos(math.radians(kaku))) 
ans = ans**0.5
print(ans)
import math

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

rad_h = 0
rad_m = 0
rad_clock = 0
parts_cos = 0
ans = 0


rad_h = h * 30 + m * 0.5
rad_m = m * 6
if rad_h < rad_m:
    rad_clock = rad_m - rad_h
elif rad_h > rad_m:
    rad_clock = rad_h - rad_m
else:
    rad_clock = 0

if rad_clock == 0:
    print(0.00000000000000000000)
else:
    ans = math.sqrt(a**2 + b**2 - (2 * a * b * (math.cos(math.radians(rad_clock)))))
    print(ans)
from math import cos, pi, sqrt
A, B, H, M = map(int, input().split())
print( sqrt( A**2 + B**2 - A*B*cos( pi*(H/6 - M/30) ) ) )
import math
A, B, H, M = map(int, input().split())
sA = (60*H+M)/360*3.141592
sB = M/30*3.141592
Ax = A*math.cos(sA)
Bx = B*math.cos(sB)
Ay = A*math.sin(sA)
By = B*math.sin(sB)
res = math.sqrt((Ax-Bx)**2+(Ay-By)**2)
print(res)
import math
A, B, H, M=map(int,input().split())
if (H == 0) & (M == 0):
    print(0)
else:
    if M != 0:
        ang_m = M / 60 * 360
    else:
        ang_m = 0
    ang_h = (H + M / 60) / 12 * 360
    ang = max(ang_h, ang_m) - min(ang_h, ang_m)
    if ang > 180:
        ang = 360 - ang
    C = math.sqrt(A**2 + B**2 - 2*A*B * math.cos(math.radians(ang)))
    print(C)
# -*- coding: utf-8 -*-
"""
Created on Sun May 17 21:16:04 2020

@author: Kei
"""

import math

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


theta_s = H*30
theta_l = M*6


theta = abs(theta_s-theta_l)

if theta > 180:
    theta = 360 - theta

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

print(C)
from sys import stdin
from math import cos, pi, sqrt
input = stdin.readline

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

x = M / 60 * 360

y = 30 * H + 1 / 2 * M

theta = max(x, y) - min(x, y)

if theta > 180:
    theta -= 180


ans = A ** 2 + B ** 2 - 2 * A * B * cos(theta / 360 * 2 * pi)

print(sqrt(ans))
import math
a,b,h,m = map(lambda x:int(x), input().split(' '))

#2つの針の長さと間の角度から距離を算出
def dst(a,b,deg):
    return ((a**2+b**2)-(2*a*b*math.cos(math.radians(deg))))**0.5

deg_1 = h*(60*h+m)*0.5
deg_2 = m*6
deg = abs(deg_1-deg_2)

if deg > 180:
    deg = 360-deg

ans = dst(a,b,deg)
print(ans)
#print(dst(3,4,90))
import math
A, B, H, M = [int(_) for _ in input().split()]


Ax = A * math.cos(math.pi/6 * (3 - H))
Ay = A * math.sin(math.pi/6 * (3 - H))
Bx = B * math.cos(math.pi/30 * (15 - M))
By = B * math.sin(math.pi/30 * (15 - M))

C = math.sqrt((Ax - Bx)**2 + (Ay - By)**2)

print(C)
import math
import numpy

a,b,h,m=map(int,input().split())
k=30*h+int(m/2)
n=6*m
tmp = n - k
tmp = math.radians(tmp)
tmp = math.cos(tmp)

ans = a**2+b**2-2*a*b*tmp
ans = numpy.sqrt(ans)
print(str(ans))
import math
a,b,h,m=map(int,input().strip().split())
ha =(60*h+m)*math.pi/360
ma = (60*h+m)*math.pi/3
# cosine rule in a triangle
c=math.sqrt(a*a+b*b-2*a*b*math.cos(ma-ha))
print("{:.20f}".format(c))
import math
a,b,h,m = map(float, input().split())

ans = (a**2 + b**2 -2*a*b*math.cos(2*math.pi*(h/12 + m/60/12)))**(1/2)
print("%.10f" % 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)
if angle > 180:
  angle -= 180

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

def main():
    a, b, H, M = map(int, input().split())

    # 時針は、１分間で0.5度（１時間で30度）
    # 分針の１分は、6度

    # 余弦定理を使用
    M_angle = 6 * M
    H_angle = 0.5 * (H * 60 + M)
    angle = int(abs(M_angle - H_angle))

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

if __name__ == "__main__":
    main()
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))))
print(math.sqrt(Answ))
import math
from decimal import Decimal

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

hrad = H*30
sind = M*6

ab = abs(hrad-sind)


ba = 360 - ab

ok = 0

if(ab > ba):
    ok = ba
else:
    ok = ab

print(ok)

tar = (A*A) + (B*B) - 2*A*B*Decimal(ok/360)

out = math.sqrt(tar)

print(out)
import numpy as np
a,b,H,M=map(int,input().split())
C=np.rad2deg(np.pi/6)*H-np.rad2deg(np.pi/30)*M
c=min(abs(C),abs(360-C))

ans=a**2+b**2-2*a*b*np.cos(np.deg2rad(c))
print(np.sqrt(ans))
import math

ji, fun, H, M = list(map(int, input().split()))

ji_kakudo = H * 30 + M * 0.5
fun_kakudo = M * 6

kakudo = int(ji_kakudo - fun_kakudo)
if 180 < kakudo:
  kakudo = 360 - kakudo

if kakudo == 180:
  print(ji + fun)
else:
  kakudo_rad = math.radians(kakudo)
  ans = math.sqrt(ji * ji + fun * fun - 2 * ji * fun * math.cos(kakudo_rad))
  print(ans)
A, B, H, M = map(int, input().split())

import math

theta = (30 * H) - (0.5 * M)

d2 = A * A + B * B - 2 * A * B * math.cos(math.radians(theta))

d = math.sqrt(d2)

print(d)
import math
a,b,h,m = map(int,input().split())
kakudo = ((h*30) + (0.5*m)) - (6*m)
if kakudo > 180:
    kakudo -= 180
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())

sh = h*30
lg = m*6

th = min(abs(sh-lg),360-abs(sh-lg))
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(th)))
import math
def sann(n):
    if n==90:
        print(math.sqrt(a**2+b**2))
    else:
        print(math.sqrt(a**2+b**2-(2*a*b*(math.cos(math.radians(n))))))

a,b,c,d=map(int,input().split())
c=c*30+d*(1/2)
d=d*6
n=abs(c-d)

if n>180:
    n=360-n
    sann(n)
elif n<180:
    sann(n)
import math

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

d_a = h * 30 + m * 0.5
d_b = m * 6
if d_a > d_b:
    d_a, d_b = d_b, d_a

d = d_b - d_a
if d > 180:
    d -= 180

print(d)

if d == 180:
    print(a + b)
else:
    print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(d))))
import math
a,b,h,m = map(int, input().split())
# print(h,m,abs(h-m))
h = 360*h/12
m = 360*m/60
x = abs(h-m)
# x = h-m
# print(h,m,abs(h-m))
# print(h,m,x)
x = math.radians(x)
# print(h,m,x)
# h = abs(h*math.pi/180)
# m = abs(m*math.pi/180)
# x = abs(h-m)
c2 = a**2 + b**2 - 2*a*b*math.cos(x)
print(math.sqrt(c2))
# print(math.pi)
# print(x*math.pi/180)
import math

pi = math.acos(-1)

a, b, h, m = (int(x) for x in input().split())

s_ang = h * 30 + m * 0.5
l_ang = m * 6

ang = abs(s_ang - l_ang)

if ang > 180:
    ang -= 180

rad = math.radians(ang)

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

if ang == 0:
    c = abs(a-b)
elif ang == 180:
    c = a+b
    
print('{:.10f}'.format(c))
import math

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

t = H * 60 + M

xh = A * math.sin(t % 720 / 720 * 2 * math.pi)
yh = A * math.cos(t % 720 / 720 * 2 * math.pi)
xm = B * math.sin(t % 60 / 60 * 2 * math.pi)
ym = B * math.cos(t % 60 / 60 * 2 * math.pi)

print(xh, yh, xm, ym)
print(math.dist((xh, yh), (xm, ym)))
import sys
import math


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, h, m = _ia()
    ad = (60*h + m) % 720
    bd = (120 * m) % 720
    dd = abs(ad-bd)
    return (a**2+b**2-2*a*b*math.cos(math.radians(dd/2)))**.5


if __name__ == "__main__":
    print(main())
import math
a,b,c,d=input().split()
a=float(a)
b=float(b)
c=float(c)
d=float(d)
sa=(30*c+0.5*d)-6*d
sa=float(sa)
if sa<0:
    sa=sa*(-1)
    sa=float(sa)
if sa>180:
    sa=sa-180
    sa=float(sa)
x=math.sqrt(a*a+b*b-2*a*b*(math.cos(math.radians(sa))))
print(x)
import math

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

rad_h = 0
rad_m = 0
rad_clock = 0
parts_cos = 0
ans = 0


rad_h = h * 30 + m * 0.5
rad_m = m * 6
if rad_h < rad_m:
    rad_clock = rad_m - rad_h
elif rad_h > rad_m:
    rad_clock = rad_h - rad_m
else:
    rad_clock = 0

if rad_clock == 0:
    print(0.00000000000000000000)
else:
    if rad_clock > 180:
        rad_clock -= 180
    parts_cos = 2 * a * b * (math.cos(math.radians(rad_clock)))
    ans = math.sqrt(a**2 + b**2 - parts_cos)
    print(ans)
import math
a,b,h,m=map(int,input().split())

def kakudo(h,m):
    jikan=30*h+0.5*m
    fun=60*m
    k=min(abs(jikan-fun),360-abs(jikan-fun))
    k=k*math.pi/180
    return k 

def cal(k):
    c=math.sqrt(a**2+b**2-2*a*b*math.cos(k))
    return c 

ans=cal(kakudo(h,m))
print(ans)
import math
a, b, h, m = map(int, input().split())
T = 2*math.acos(-1)
# print(T)
# print((h * T / 12), (m * T / 60))
dif = max((h * T / 12), (m * T / 60)) - min((h * T / 12), (m * T / 60))
# print(dif)
print(f'{math.sqrt((a*a) + (b*b) - (2*a*b*math.cos(dif))):.9f}')
import math
num = input().split()
A = int(num[0])
B = int(num[1])
H = int(num[2])
M = int(num[3])
H1 = 30*H
M1 = 6*M
c = min((360-(max(H1, M1)-min(H1, M1))), (max(H1, M1)-min(H1, M1)))
C = A**2 + B**2 - (2 * A * B * (math.cos(math.radians(c))))
print(math.sqrt(C))
import math
from decimal import Decimal
 
A,B,H,M = map(Decimal,input().split())
 
hrad = H*30
sind = M*6
 
ab = abs(hrad-sind)
 
 
ba = 360 - ab
 
ok = 0
 
if(ab > ba):
    ok = ba
else:
    ok = ab
 

 
tar = (A*A) + (B*B) - 2*A*B*Decimal(ok/360)
 
out = math.sqrt(tar)
 
print(out)
import math
a,b,h,m=map(int,input().split())
h=h*10+m*0.5
kakudo=abs(max(h,m)-min(h,m))
if kakudo>180:
    kakudo-=180
c=math.cos(math.radians(kakudo))
ans=a**2+b**2-2*a*b*c
ans=ans**0.5
print(ans)
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
# t=int(input())
t=1
for _ in range(t):
    # n,m=map(int,stdin.readline().split())
    a,b,h,m=map(int,stdin.readline().split())
    hang=(h+(m/60))*30
    mang=m*6
    ang=abs(hang-mang)
    if(ang>180):
        ang=ang-180
    # print(hang,mang,ang)
    ang=ang*math.pi/180
    ans=math.sqrt(((a*math.sin(ang))**2)+((b-(a*math.cos(ang)))**2))
    print(ans)