peterverebics/CodeNet_Python_118 huggingface dataset:
import math
a,b,h,m = map(int,input().split())
ans = 0
ang = 0

if 6*m == 30*h+0.5*m:
  ans = 1
elif abs(6*m - 30*h+0.5*m) == 180:
  ans = 7
  ang = 180
elif 6*m > 30*h+0.5*m:
  ang = 6*m - 30*h+0.5*m
  ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang)))
else:
  ang = 30*h+0.5*m + (360 - 6*m)
  if ang > 360:
    ang -= 360
  ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang)))
print(ans)
import math

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

total_min = 60 * H + M
ch = (360/(12*60)) * total_min
cm = 360/60 * M

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

def main():
    a,b,h,m = map(int,input().split())
    fun = h*60 + m
    angleM = (fun * 60) % 360
    angleH = (fun * 0.5) % 360

    print((a*a + b*b - 2*a*b*math.cos(math.radians(abs(angleH - angleM)))) ** 0.5)


    # print(fun,angleM,angleH)


if __name__ == "__main__":
    main()
import math as mt
a, b, h, m = list(map(int, input().split()))
h_e = 360/12
m_e = 360/60


ang = abs(h_e*(h + m/60) - m*m_e)
if ang > 180:
  ang %= 180
print('{:.12f}'.format(mt.sqrt(a*a + b*b -2*a*b*mt.cos(ang/360*2*mt.pi))))
from math import cos, sqrt, radians

def main():
    a, b, h, m = map(int, input().split())
    h_angle = (h * 60 + m) / 2 # 時針の角度
    m_angle = m * 6 # 分針の角度
    theta = abs(h_angle - m_angle)
    
    if theta > 180:
        theta -= 180
        
    x_2 = a**2 + b**2 - 2*a*b*cos(radians(theta))
    print(sqrt(x_2))
    
    
main()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math as mt

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

    theta1 = 30*H + M/2
    theta2 = 60*M

    xx = A**2 + B**2 - 2*A*B*mt.cos(mt.radians(theta2-theta1))
    print(mt.sqrt(xx))


if __name__ == '__main__':
    main()
import math
A, B, H, M = map(int, input().split())
deg = H*30-M*0.5
ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(deg))
print(ans**0.5)
a,b,h,m=map(int,input().split())
import math
angle=abs(5.5*m+30*h)/180
ans=a**2+b**2-2*a*b*math.cos(angle*math.pi)
print(ans**(1/2))
import math

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

diff = abs(30 * H - 6 * M)
rad = math.radians(diff)
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))

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

long = M * 6
short = (H*60 + M) * 0.5
k = short - long
if k > 180:
    k -= 180
a = (A**2) + (B**2) - (2*A*B*math.cos(math.radians(k)))
ans = a**(1/2)
if k == 180:
    ans = A+B
print(ans)
import math
a, b, h, m = map(int, input().split())

rh = h*30 + m*0.5
rm = m*60
angleC = abs(rh - rm)
if angleC > 180:
    angleC = 360 - angleC

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

Radians = math.radians(C)
COS= math.cos(Radians)
cosRounded= round(COS,2)
ans = (A**2) + (B**2) - 2*(A*B)*cosRounded
print(ans**0.5)
import math
a,b,h,m=map(int,input().split())
if(h==0 and m==0):
  print(0)
else:  
  ah=(h*30)+(m*0.5)
  am=m*6
  an=abs(ah-am)
  f=abs(360-an)
  ang=min(an,f)
  d=math.cos(math.radians(ang))
  z=math.sqrt((a**2)+(b**2)-(2*b*a*d))
  print(z)
import math
 
a, b, h, m = map(int, input().split())
 
r = abs((h * 30 + m / 2) - m * 6)
if r > 180:
    r = r - 180
 
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(r)))
print(c)
import numpy as np

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

hour = np.array([a * np.cos(h * 2 * np.pi / 24), a * np.sin(h * 2 * np.pi / 24)])
mins = np.array([b * np.cos(m * 2 * np.pi / 60), b * np.sin(m * 2 * np.pi / 60)])

r = np.sqrt(np.linalg.norm(hour) ** 2 + np.linalg.norm(mins) ** 2)

print(r)
import math
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if 180 <= r:
  r1 = r -180
else:
  r1 = r
cos = math.cos(math.radians(r1))
d = a1 + b1 - 2 * ab * cos
ans = d ** (1/2)
print(ans)
import sys
import math

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    A, B, H, M = MI()
    th_h = H / 12 * 360 
    th_m = M / 60 * 360 
    theta = abs(th_h-th_m)
    rad = math.radians(theta)
    ans2 = pow(A,2) + pow(B,2) - 2*A*B*math.cos(rad)
    #print(2*A*B*math.cos(rad))

    print(pow(ans2,0.5))


if __name__ == "__main__":
	main()
import math
 
a,b,h,m=map(int,input().split())
mins=60*h+m
c=(mins*6)
d=mins/2
rads=(max(abs(c-d),180-abs(d-c))*math.pi/180)
dist=math.sqrt(a*a+b*b-2*a*b*math.cos(rads))
print(dist)
import numpy as np
A, B, H, M = map(int,input().split())
time = 60*H + M #経過時間(分)

rad_h = (np.pi/360)*time
rad_m = (np.pi/30)*M

rad = np.abs(rad_h-rad_m)
if rad>np.pi:
  rad = rad-np.pi

l = np.sqrt(A**2+B**2-2*A*B*np.cos(rad))
  
print(l)
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-59*M/60)/12
length_squared = A**2 + B**2 - 2*A*B*np.cos(angle)
length = np.sqrt(length_squared)
#print('{:10f}'.format(length))
print(length)
import sys
import math
input = sys.stdin.readline


def main():
    A, B, H, M = map(int, input().split())
    x = abs(H * 30-M*6)
    theta = min(x, 360-x)
    if theta == 180:
        print(A+B)
    elif theta == 0:
        print(abs(A-B))
    else:
        print(math.sqrt(A**2+B**2-2*A*B*round(math.cos(math.radians(theta)), 2)))


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

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

if a==b:
    print(abs(A-B))
    exit()
elif a < b:
    dif = b - a
else:
    dif = a - b

if int(dif) == 180:
    print(A+B)
else:
    deg = dif%180
    print(math.sqrt(pow(A,2)+pow(B,2)-(2*A*B*math.cos(math.radians(deg)))))
import math

A,B,H,M = map(int,input().split())
MM = 6*M #分針の角度
HH = H*30 + M//2
if(MM-HH>=0):
    rad = MM-HH
    cosine = math.cos(math.radians(rad))
else:
    rad = MM-HH
    cosine = math.cos(math.radians(0-rad))
    

r = math.sqrt(A**2+B**2-2*A*B*cosine)
print(r)
import math

str = input().split()
a = int(str[0])
b = int(str[1])
h = int(str[2])
m = int(str[3])

rm =  m*6;         # m/60*360;
rh =  (h*60+m)/2;  # m/720*360;

diff = abs(rm - rh) % 180;
rd = diff * math.pi/180

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

A,B,H,M = map(int, input().split())
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-2*A*B*math.cos(math.radians(X))
if X ==0:
  print(A+B)
else:
  print(C**0.5)
import math
a,b,h,m=map(int,input().split())
ha=(h*60+m)/720*360
ma=m/60*360
angle=max(ha,ma)-min(ha,ma)
if angle>179:
  angle-=180
angle=angle/180*math.pi
#print(ha,ma,angle,math.cos(angle))
ans=math.sqrt(a*a+b*b-2*a*b*math.cos(angle))
print(ans)
# coding:utf-8
import math


def degree(h, m):
    return abs((h * 30) - (m * 6))


A, B, H, M = map(int, input().split(' '))
d = degree(H, M)
if d == 0:
    print(d)
    print(B - A)
else:
    if d > 180:
        d = d - 180
    print(d)
    C2 = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(math.radians(d)))
    print(C2)
    print(math.sqrt(C2))
A,B,H,M = map(int,input().split())
import math

d = 30*(H%12)+0.5*M -6*M

if d<0:
    d = -d

if d>180:
    d = 360 -d

print(d)

c = A**2 + B**2 - 2*A*B*math.cos(math.radians(d))

print(math.sqrt(c))
import math

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

H %= 12

B_ang = 6*M
A_ang = 30*H + (0.5*M)
AB_cos = math.cos(math.radians(min(abs(360 - A_ang - B_ang), abs(B_ang - A_ang))))
ans = math.sqrt(A**2 + B**2 - (2*A*B*AB_cos))

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

sho_deg = h*0 + m*6 #6(deg/m)
lon_deg = h*30 + m*0.5 #0.5(deg/m)

deg_dif = abs((sho_deg-lon_deg)%180)

print((a**2 + b**2-2*a*b*math.cos(deg_dif/180*math.pi))**0.5)
import math

def kyori(a,b,c,d):
    return math.sqrt(a**2+b**2-2*a*b*math.cos(abs(c-d)))

A, B, H, M = [int(i) for i in input().split()]
m = M* 2*math.pi/60 #rad
h = H* 2*math.pi/12+ m*2*math.pi/12/60 #rad
#print(h, "\n", m)


k=kyori(A,B,h,m)
print(k)
import math
a,b,h,m = map(int,input().split())
short = h*30+m/2
long = m*6
ang = abs(short-long)
ang = ang if ang <= 180 else ang-180
if ang==0:
  print(0)
else:
  hen = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang)))
  print(hen)
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
A, B, H, M = map(int, input().split())
h = (H / 12 + M / 720)
m = M / 60
rad = (abs(h-m) * 360) % 180
if int(rad) == 0:
    print(abs(A - B))
elif int(rad) == 180:
    print(A + B)
else:
    print( round((A**2 + B**2 - 2 * A * B *  round(math.cos( math.radians(rad) ),20) )** 0.5, 10) )
import numpy as np
def main():
    A, B, H, M = map(int, input().split())
    omega_m = 1.0/60.0
    omega_h = 1.0/12.0
    a = (H + M/60.0) * omega_h
    b = (60.0*H + M) * omega_m
    theta = (a - b) * 360.0
    c = np.sqrt(A**2 + B**2 - 2.0*A*B*np.abs(np.cos(theta/180.0*np.pi)))
    print(c)
if __name__ == '__main__':
    main()
A,B,H,M=map(int,input().split())
import math

if abs(H*30-M*6)<=180:
    C=A**2+B**2-2*A*B*math.cos(math.radians(abs(H*30-M*6)))
    print(math.sqrt(C))
else:
    C=A**2+B**2-2*A*B*math.cos(math.radians((180-abs(H*30-M*6))))
    print(math.sqrt(C))
# coding: utf-8
# Your code here!

import math

a,b,h,m=map(int,input().split())
d=abs(h-m)
d=min(12-d,d)*30
c=a**2+b**2-2*a*b*math.cos(math.radians(d))
print(c**(1/2))
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*a)+(b*b)-(2*a*b*math.cos(ang)))
    print(ans)
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(C**0.5)
import math
a, b, h, m = map(float, input().split())
ji = ((60 * h + m) / 720) * 2 * math.pi
hu = (m / 60) * 2 * math.pi
kaku = abs(ji - hu)
if kaku >= math.pi:
    kaku -= math.pi
ans = (a ** 2 + b ** 2 - 2 * a * b * math.cos(kaku)) ** (1/2)
print(ans)
import math

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

ha = 30 * H + 0.5 * M
if M == 0 :
    ma = 360
else:
    ma = 6 * M

if ha > ma:
    an = ha - ma
    print((A**2 + B**2 - (2 * A * B * round(math.cos(math.radians(an)),9)))**0.5)
elif ma > ha:
    an = ma - ha
    print((A**2 + B**2 - (2 * A * B * round(math.cos(math.radians(an)),9)))**0.5)
else:
    if H == 6 and M == 0:
        print(A+B)
    else:
        print(0.0000000000000000)
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)

if target_angle > math.pi:
    target_angle = 2 * math.pi - target_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())
h_angle = 360 * h / 12
m_angle = 360 * m / 60
angle = abs(h_angle - m_angle)
print(angle)
print(a * a)
print(b * b)
aa = a * a + b * b - 2 * a * b * math.cos(math.radians(angle))
print(math.sqrt(aa))
import math
A,B,H,M = map(int,input().split())
H_pos = H/12 + M/720
M_pos = M/60
print("{:.10f}".format((A**2+B**2-2*A*B*math.fabs(math.cos(math.radians(360*math.fabs(H_pos-M_pos)))))**0.5))
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 = ar+br if (ar+br) <= 180 else max(ar, br) - min(ar, br)
    ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(kakudo * math.pi / 180))
    print(ans)
if __name__ == "__main__":
    main()
import math
pi = math.pi

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

if H <= 3:
    h = (3-H)* 2*pi/12
else :
    h = 2*pi/3 + (11-H) * 2*pi/12
if  M <= 15:
    m = (15-M) * pi/30
else :
    m = 2*pi*16/60 + (59-M)* pi/30
# print(H,M)
# print(h/pi,'pi', m/pi)
x = A*math.cos(h) + B*math.cos(m)
y = A*math.sin(h) + B*math.sin(m)  
d = (x**2 + y**2)**(1/2)
print(round(d,9))
import sys
import math
import itertools

a, b, h, m = map(int, input().split())
ans=0
deg = max(h / 12, m / 60)*360 - min(h / 12, m / 60)*360
if (deg > 180):
    deg = 360 - deg
print(math.sqrt(a ** 2 + b ** 2 - (2 * a * b * math.cos(math.radians(deg)))))
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)
  
c=a**2+b**2-2*a*b*math.cos(math.radians(sa))
print(math.sqrt(c))
import math
def yogen(rad, a, b):
    x = math.sqrt(a*a + b*b -2*a*b*math.cos(rad))
    return x
    
def rad(h, m):
    h = h*30 + 30 * m/60
    m = m*6
    x = abs(h - m)
    if x > 180:
        x -= 180
    print(x)
    return math.radians(x)
    
a, b, h, m = map(int, input().split())
print(yogen(rad(h, m), a, b))
import sys
import math

sys.setrecursionlimit(500005)
stdin = sys.stdin

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

a, b, h, m = na()
hh = math.pi*2*(h/12+m/60/12)
mm = math.pi*2*m/60
print(a, b)
ax = math.cos(hh)*a
ay = math.sin(hh)*a
bx = math.cos(mm)*b
by = math.sin(mm)*b
print(f"{math.sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)):.14f}")
import math

A, B, H, M = map(int, input().split())
theta = math.radians(abs(H*30+M//2.0 - M*6))
print(math.sqrt(A**2 + B ** 2 - 2 * A * B * math.cos(theta)))
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

cc = A ** 2 + B ** 2 - (2 * B * A * math.cos(math.radians(K)))
print(math.sqrt(cc))
import cmath
import math
ph = math.pi
A, B, H, M = map(float, input().split())
Aarg = ph*H/6
Aarg += ph*M/72
#a = cmath.rect(A, Aarg)
Barg = ph*M/6
#b = cmath.rect(B, Barg)
#print(abs(a-b))
print(math.sqrt(A**2+B**2-2*A*B*math.cos(Aarg-Barg)))
import math
A,B,H,M = map(int,input().split())
ang = H*math.pi/6 - M*math.pi/30
print( math.sqrt(A*A+B*B-2*A*B*math.cos(ang)))
import math

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

theta = 360 * abs(M / 60 - H / 12)
if theta > 180:
    theta = 360 - theta

print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(theta))))
import math
a,b,h,m = map(int,input().split())

if h==0:
    hh = 0
else:
    hh = 360*(h/12)
if m==0:
    mm = 0
else:
    mm = 360*(m/60)
    
x = int(abs(mm-hh))
if x > 180:
    x = 360 - x

a2 = a**2
b2 = b**2

ans = math.sqrt((a2+b2)-(2*a*b*round(math.cos(math.radians(x)),0)))
print(ans)
import math
def main():
    A,B,H,M = map(int, input().split())
    h = 360*H/12 + 30*M/60
    m = 360*M/60
    theta = min(abs(h-m), abs(360-(h-m)))
    print(theta)
    cos = math.cos(math.radians(theta))
    ans = pow(A,2)+pow(B,2)-2*A*B*cos
    print(math.sqrt(ans))

main()
import math

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

H = H*5 + (5/60)*M

comp = abs(H-M)

if(comp>=30):
    comp = 60-comp

print(comp)

pre = ((comp*6)/360)*2*math.pi

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

print(math.sqrt(ans))
import math
 
a,b,h,m = map(int, input().split())
h1 = h * 30
m1 = m * 5.5
r = abs(h1 - m1)
a1 = a ** 2
b1 = b ** 2
ab = a * b
if r == 0:
  print(abs(a-b))
elif r == 180:
  print(a + b)
elif 180 < r:
  r1 = r -180
  cos = math.cos(math.radians(r1))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)
else:
  cos = math.cos(math.radians(r))
  d = a1 + b1 - 2 * ab * cos
  ans = d ** (1/2)
  print(ans)
import math
from decimal import Decimal

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

deg = abs((h)*5 - m) * 6 + (m/2)#度
length = Decimal(str(a*a + b*b - 2*a*b*math.cos(math.radians(deg))))**Decimal('0.5')

print(length)
A,B,H,M = map(int,input().split())
minutes = H*60 + M
angle_pm_h = 360 / (12 * 60)
angle_pm_m = 360 / 60
angle_h = angle_pm_h * minutes
angle_m = angle_pm_m * M % 360
angle = abs(angle_h - angle_m)
angle = angle if angle < 180 else angle-180
import math
ans = math.sqrt(A*A + B*B - 2 * A * B * math.cos(math.radians(angle)))
print(ans)
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(0)
else:
  print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(d))))
from math import cos, radians

def main():
    a, b, h, m = map(int, input().split())
    h_angle = (h * 60 + m) / 2 # 時針の角度
    m_angle = m * 6 # 分針の角度
    theta = abs(h_angle - m_angle)
    
    if theta > 180:
        theta -= 180
        
    x_2 = a**2  + b**2 - 2*a*b*cos(radians(theta))
    print(x_2 ** 0.5)
    
main()
import math
from sys import stdin


def get_result(data):
    A, B, H, M = data
    h_deg = (H + M/60) * 30.0
    m_deg = M * 6.0
    theta = math.radians(abs(m_deg-h_deg) % 180)
    ans = math.sqrt((A**2+B**2 - 2*A*B*math.cos(theta)))
    return ans


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

rad_h = 90 - h*30
rad_m = 90 - m*6

ax = a * math.cos(math.radians(rad_h))
ay = a * math.sin(math.radians(rad_h))

bx = b * math.cos(math.radians(rad_m))
by = b * math.sin(math.radians(rad_m))

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

print(ans)
import math
a, b, h, m = map(int, input().split())
x = 30 * h + (m * 0.5) % 360
y = m * 6
#print(x,y)
sa = abs(x - y)#2辺のなす角
if a > b:#長辺をb短辺をaに設定
    c = b
    b = a
    a = c
#print(a,b,c)
t = (math.sin(math.radians(sa))) * b
f = math.sqrt(b ** 2 - t ** 2)
'''
if sa >= 90:#鈍角であった場合
    a = -a
'''
print(math.sqrt((f - a) ** 2 + t ** 2))#辺の長さに直す
import math
A, B, H, M = map(int, input().split())
thetaA = math.pi * (0.5*(H*60 + M)) / 180
thetaB = math.pi * 6.0*M / 180
cosC = abs(math.cos(thetaA-thetaB))
ans = math.sqrt(A**2+B**2-2*A*B*cosC)
print(ans)
import math
a, b, h, m = map(int, input().split())
t_a = 0.5*(h*60+m)
t_b = 6*m
c = math.cos(((t_a - t_b) % 181)*2*math.pi/360.0)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * c), end="")
import math

def main():
    a,b,h,m = map(int, input().split())
    l_hand = 6 * m
    s_hand = 30 * h + m / 2
    theta = abs(l_hand - s_hand)

    if theta > 180:
        theta = 180 - theta
    
    ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(theta))
    print(math.sqrt(ans))

if __name__ == "__main__":
    main()
import math
#A:短針,B:長針,H:短針の位置,M:長針の位置
A,B,H,M = map(int,input().split(' '))

#時計は毎分6度進む:a^2 = b^2+c^2-2bc*cosA
if H >= 6:
    edge = abs(M*6+(12-H)*5*6)
else:
    edge = abs(M*6-H*5*6)

if edge > 180:
    edge = 360 - edge

if edge%180 == 0:
    print('{:.15f}'.format(A+B))
else:
    print('{:.15f}'.format(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(edge)))))
import math
A, B, H, M = map(int, input().split())

H_deg = H*30 + M*0.5 if H <= 6 else (H-12)*-1*30 - M*0.5
M_deg = M*6
if M <= H*5:
    degree = H_deg + M_deg
else:
    degree = M_deg - H_deg

if degree == 180:
    print(A+B)
elif degree < 180:
    c = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(degree)))
    print(c)
else:
    c = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(360-degree)))
    print(c)
import math
a,b,h,m = map(float, input().split()) 

h_kaku=(math.pi/6)*h
m_kaku=(math.pi/30)*m

h_x=a*math.cos(h_kaku)
h_y=a*math.sin(h_kaku)
m_x=b*math.cos(m_kaku)
m_y=b*math.sin(m_kaku)

ans=(h_x-m_x)**2+(h_y-m_y)**2

print(ans**(1/2))
import math
A, B, H, M = map(int, input().split())
v1, v2 = math.pi / 360, math.pi/30 #単身、長身

# H, M の角度
#単身進んだ角度
#0時からの経過分　かける　速度
sec = 60*H + M
ang1 = v1*(60*H + M)
ang2 = v2*M
#print(ang1, ang2)

#針のなす角度
ang = abs(ang1- ang2)
if ang > math.pi:
    ang = ang-math.pi

# 余弦定理
out = math.sqrt(A*A + B*B - 2*A*B*math.cos(ang) )
print(out)
import numpy as np
A, B, H, M = map(int, input().split())

H_speed = np.pi / (6)
M_speed = np.pi / 30
H_angle = H * H_speed
M_angle = M * M_speed
H = np.array([A * np.cos(H_angle), A * np.sin(H_angle)])
M = np.array([B * np.cos(M_angle), B * np.sin(M_angle)])
HM = H - M
print(np.linalg.norm(HM))
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
print(kakudo)
c=math.cos(math.radians(kakudo))
ans=a**2+b**2-2*a*b*c
ans=ans**0.5
print(ans)
a,b,h,m = list(map(int, input().split()))


h %= 12
m %= 60
h = h/12
m = m/60
h *= 360
m *= 360
#print(m,h)
h += (m/360)*30
ans = abs(h-m)
ans %= 180
#print(ans,h,m)
#c2 = a2+b2 -2abCosC

from math import cos,radians

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

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

rot_a = h*30 + m*0.5
rot_b = m*6
rot = rot_a-rot_b if rot_a>rot_b else rot_b-rot_a
if rot > 180:
  rot = min(rot_a, rot_b) + 360 - max(rot_a, rot_b)

ans = sqrt(a**2 + b**2 - 2*a*b*cos(rot*pi/180))
print(rot)
print(ans)
A, B, H, M = list(map(int, input().split()))

m = 360/60 * M
h = 360/12 * (H + M/60)
deg = abs(h-m)
if deg>180: deg = 360-deg

import math

Csq = A**2 + B**2 - 2*A*B*math.cos(math.radians(deg))
print('{:.10f}'.format(math.sqrt(Csq)))

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

deg = abs((360 / 720) * (60 * H + M) - 6 * M)

if deg == 180:
    print(A + B)
elif deg == 0:
    print(abs(A - B))
else:
    if deg > 180:
        deg -= 180
    theta = math.radians(deg)
    c2 = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(theta))

    print(math.sqrt(c2))
import math
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))

print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))))
import math
if __name__ == '__main__':
    pi=3.1415926535
    a,b,h,m=map(int,input().split())
    ang1=h/12*2*pi
    ang2=m/60*2*pi

    if ang1>=ang2:
        ang=(ang1-ang2)
    else :
        ang=(ang2-ang1)
    ans=a**2+b**2-2*a*b*(math.cos(ang))
    print(ang)
import math

a, b, h, m = map(int, input().split())
deg_a = math.pi * (60 * h + m) / 360
deg_b = math.pi * m / 30
if (abs(deg_a - deg_b) > math.pi):
    deg_c = abs(deg_a - deg_b) - math.pi
else:
    deg_c = abs(deg_a - deg_b)

c = math.sqrt(a*a + b*b - 2 * a * b * math.cos(deg_c))
print(c)
import math
A, B, H, M = map(int, input().split())
if H==0:
    H = 60
else:
    H *= 5
e = M/12
if M==0:
    M = 60
deg =abs(H+e-M)*6
if deg==0:
    print(0)
    exit()
cos = math.cos(math.radians(deg))
print(((A**2)+(B**2)-2*A*B*cos)**0.5)
import math 

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

theta = min(360-abs(6*m-30*h),abs(6*m-30*h))
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(theta)))

print(ans)
import math

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

rad_M = math.radians(60*M)
rad_H = math.radians(30*H+0.5*M)
rad = abs(rad_M-rad_H)
if rad >= math.pi:
  rad = 2*math.pi - rad

S = (A**2) + (B**2) - 2*A*B*math.cos(rad)
S = S**0.5
print(S)
import math
a,b,h,m=map(int,input().strip().split())
ha =(60*h+m)*math.pi/360
ma = (6*h+m)*math.pi/3
# cosine rule in a triangle
c=math.sqrt(a*a+b*b-2*a*b*math.cos(abs(ma-ha)%(2*math.pi)))
print("{:.20f}".format(c))
import math
a,b,h,m = list(map(int,input().split()))

#角度 
hsita = 30 * h
msita = 6 * m

#位置
hx = math.cos(math.radians(hsita)) * a
hy = math.sin(math.radians(hsita)) * a
mx = math.cos(math.radians(msita)) * b
my = math.sin(math.radians(msita)) * b

#3heiho
ans = math.sqrt(((hx - mx) ** 2) + ((hy-my)**2))

print(ans)