Problem:
 Score: 300 points    Problem Statement  Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?      Constraints   All values in input are integers.  1 \leq A, B \leq 1000  0 \leq H \leq 11  0 \leq M \leq 59         Input  Input is given from Standard Input in the following format:  A  B  H  M       Output  Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9} .        Sample Input 1 3 4 9 0      Sample Output 1 5.00000000000000000000  The two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.        Sample Input 2 3 4 10 40      Sample Output 2 4.56425719433005567605  The two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.

Solution (Python):
import sys
from math import cos, radians, sqrt

a, b, h, m = [int(i) for i in sys.stdin.readline().split()]
theta_m = 360 * (m / 60)
theta_h = 30 * (m / 60) + 30 * h
diff_theta = min(abs(360 - abs(theta_h - theta_m)), abs(theta_h - theta_m))
c = sqrt(a**2 + b**2 - 2 * a * b * cos(radians(diff_theta)))
print(c)

Solution (Python):
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) )

Solution (Python):
import math
a, b, h, m = map(int, input().split())

minuterad = m/60*360
hourrad = (h*60+m)/720*360

rad = abs(minuterad - hourrad)

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

print(ans)

Solution (Python):
import math

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

rada = 0.5 * (h * 60 + m)
radb = 6 * m

rad = rada - radb
rad = rad / 180 * math.pi
    
l = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(l)

Solution (Python):
import math
a, b, h, m = map(int, input().split())



minuterad = m/60*360
hourrad = (h*60+m)/720*360
minx, miny = b*math.cos(math.radians(minuterad)), b*math.sin(math.radians(minuterad))
hourx, houry = a*math.cos(math.radians(hourrad)), a*math.sin(math.radians(hourrad))
ans = math.sqrt((minx-hourx)**2 + (miny-houry)**2)

print(ans)

Solution (Python):
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))))

Solution (Python):
import sys, math
input = sys.stdin.readline

def main():
    A, B, H, M = map(int, input().split())
    a = math.pi * 2 * (((H % 12) / 12) + M / 60 / 12)
    b = math.pi * 2 * (M / 60)
    ax, ay = A * math.cos(a), A * math.sin(a)
    bx, by = B * math.cos(b), B * math.sin(b)
    print(pow((ax - bx)**2 + (ay - by)**2, 0.5))


if __name__ == "__main__":
    main()

Solution (Python):
import math
a, b, h, m = map(int, input().split())
m_rad = 6 * m
h_rad = 0.5 * 60 * h + 0.5 * m
length = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(abs(m_rad - h_rad))))
print('{:.10f}'.format(length))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
m_rad = 6 * m
h_rad = 0.5 * 60 * h + 0.5 * m
length = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(abs(m_rad - h_rad))))
print('{:.20f}'.format(length))

Solution (Python):
import math
a, b, h, m = map(int,input().split())
f = h * 30 + m * 0.5 
g = m * 6 
mm = abs(f - g)
l = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(mm)))
print('{:.20f}'.format(l))

Solution (Python):
import math
a,b,h,m = map(int,input().split())
hoge = (h/12+m/720-m/60)*360
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(hoge))))

Solution (Python):

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


C=(H*30+M*0.5-M*6)
if C < 0:
    C = -C

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())

rh = h*30 + m*0.5
rm = m*6
angleC = math.radians(abs(rh - rm))
if angleC > math.pi:
    angleC = math.pi*2 - angleC

c = a**2 + b**2 - 2*a*b * math.cos(angleC)
print(math.sqrt(c))

Solution (Python):
from math import cos, radians, sqrt

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

ab = abs(0.5*((h*60)+m)) - (6.0*m)
ab = min(ab, 360-ab)

c = a*a + b*b - 2*a*b*cos(radians(ab))
print(sqrt(c))

Solution (Python):
import math

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

ho = (h+(m/60))*360/12
mi = m*360/60
diff = abs(ho - mi)

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(diff)))
print(f'{ans:.19f}')

Solution (Python):
import math

A,B,H,M=map(int,input().split())
angle=abs(360*(H%12+M/60)/12-360*M/60)
angle=math.radians(min(angle,360-angle))
print((A**2+B**2-2*A*B*math.cos(angle))**0.5)

Solution (Python):
import math

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

h_rad = ((12-h)/6 - m/(60*6))*math.pi
m_rad = (60-m)/30*math.pi

x = a * math.cos(h_rad) - b * math.cos(m_rad)
y = a * math.sin(h_rad) - b * math.sin(m_rad)

distance = math.sqrt(x**2 + y**2)
print(distance)

Solution (Python):
import math

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

theta = 2 * math.pi * abs((H+M/60)/12 - M/60)
dist = math.sqrt(A**2 + B**2 - (2*A*B*math.cos(theta)))
print(dist)

Solution (Python):
import math
A,B,H,M = map(int,input().split())

H %= 12
ra = 0.5*(60*H+M)-6*M
ra = min(ra,360-ra)
cos_ra = math.radians(ra)
C = math.sqrt((A**2+B**2)-(2*A*B*math.cos(cos_ra)))
print(C)

Solution (Python):
"""
cosA=((AB)**2 + (AC)**2 - (BC)**2)/2(AB)(AC)
三角形の求め方
三辺もしくは二辺+1角度わかれば行ける
＜正弦定理＞<余弦定理>
"""
import math
a = [int(i) for i in input().split()]

zisin = a[0]
kakudo_z = a[2]*30+a[3]*0.5
hunsin = a[1]
kakudo_h = a[3]*6
kakudo = abs(kakudo_h-kakudo_z)
if kakudo > 180:
    kakudo = 360 - kakudo
if kakudo != 90:
    print (f'{math.sqrt(a[0]**2+a[1]**2-(math.cos(math.radians(kakudo)))*2*a[0]*a[1]):0.20f}')
else:
    print(f'{math.sqrt(a[0]**2+a[1]**2):0.20f}')

Solution (Python):
import math
A, B, H, M = map(int, input().split())

H = (60 * H + M) * (360 / (60 * 12))
M = M * 6
ang = abs(H - M)  
rad = math.radians(ang)

C = A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)
print(C ** 0.5)

Solution (Python):
import numpy as np

A, B, H, M = map(int, input().split())
angM = np.pi*M/30
angH = np.pi*(60*H+M)/360
d = np.sqrt(A**2 + B**2 - 2*A*B*np.cos(angH - angM))
print(d)

Solution (Python):
import math

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

m2 = 6 * m
h2 = 30 * h + m*30/60
kakudo = abs(h2-m2)

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

Solution (Python):
import math

org_in = input()
Z = []
for i in org_in.split():
    Z.append(int(i))
    
A = Z[0]
B = Z[1]
H = Z[2]
M = Z[3]
    
alpha = 2*math.pi * ( 60*H + M ) / 720
beta = 2*math.pi * M / 60
theta = alpha - beta

length = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta))

print(length)

Solution (Python):
import math

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

x = A*math.cos(M/60* 2* math.pi) - B*math.cos( (H*60 + M)/720* 2*math.pi)
y = A*math.sin(M/60* 2* math.pi) - B*math.sin( (H*60 + M)/720* 2*math.pi)

print((x**2 + y ** 2)**0.5)

Solution (Python):
import math
A,B,H,M = map(int, input().split())

h = H/6 + M/360
m = M/30

CC = A*A + B*B - 2*A*B*math.cos((h-m)*math.pi)
C = math.sqrt(CC)
print(C)

Solution (Python):
import math

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

hhour = [A * math.cos(math.pi * M/30), A * math.sin(math.pi * M/30)]
mmin = [B * math.cos(math.pi * (H+M/60)/6), B * math.sin(math.pi * (H+M/60)/6)]

print(math.sqrt(abs(hhour[0]-mmin[0])**2+abs(hhour[1]-mmin[1])**2))

Solution (Python):
from math import pi, cos, sqrt

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

rad = abs((h+(m/60))/12 - m/60)*pi*2
c = sqrt(a**2 + b**2 - 2*a*b*cos(rad))

print(c)

Solution (Python):
import math
a,b,h,m = map(int,input().split())

h_angle = 30 * h
m_angle = 12 * m
diff = 2 * math.pi * (m / 60 - (h + m / 60) / 12)

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
diff_hm = abs(h*30 + m*0.5 - m*6)
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(diff_hm))))

Solution (Python):
import math

a, b, h, m = list(map(int, input().split()))
deg = 30 * h - 6 * m + 30 * (m / 60.0)
if deg < 0:
  deg += 360
elif deg > 180:
  deg = 360 - deg

cos = math.cos(math.radians(deg))
c_2 = a * a + b * b - 2 * a * b * cos
print(math.sqrt(c_2))

Solution (Python):
import math

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



h_rad = ((12-h)/6 - m/(30*12) )*math.pi
m_rad = ((60-m)/30)*math.pi


x = a * math.cos(h_rad) - b * math.cos(m_rad)
y = a * math.sin(h_rad) - b * math.sin(m_rad)
ans = math.sqrt(x**2 + y**2)

print(ans)

Solution (Python):
import math

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

Hangle = (H + (M/60))/12*360
Mangle = M/60*360
angle = abs(Hangle - Mangle)

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

print(C)

Solution (Python):
import math
a,b,h,m = map(int,input().split())

radian_m = 6*m

radian_h = 30*h + m/2



f = radian_h - radian_m
c_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(f))
c = math.sqrt(c_2)
print(c)

Solution (Python):
import math
a,b,h,m = map(int, input().split())

deg_a = (60 * h + m) * (360 / (60 * 12))
deg_b = m * (360 / 60)
deg = abs(deg_a - deg_b)
rad = math.radians(deg)

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)

Solution (Python):
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)

Solution (Python):
import math

def Colon():
    input_str = input()
    input_list = input_str.split()
    A = float(input_list[0])
    B = float(input_list[1])
    H = float(input_list[2])
    M = float(input_list[3])
    
    H_speed_per_min = 360/(12*60)
    M_speed_per_min = 360/60
    
    passed_min =    H*60 + M
    H_deg = math.radians(H_speed_per_min * passed_min)
    M_deg = math.radians(M_speed_per_min * (passed_min % 60))
    theta = H_deg - M_deg
 
    C = (A**2 + B**2 - 2*A*B*math.cos(theta))**0.5
    print(C)
    
Colon()

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

import math

theta = math.radians(abs((h / 12 * 360 + m / 2) - (m / 60 * 360)))

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

ans = math.sqrt(cc)

print(ans)

Solution (Python):
import math
a,b,h,m = map(int, input().split())

x = (60*h+m)*11 /360
for i in range(1,23,2):
    if x < i:
        sita = x * math.pi
        ans_2 = a**2 + b**2 - 2*a*b * math.cos(sita)
        print(ans_2 ** 0.5)
        exit()
    elif i < x < i + 2:
        sita = abs(x-2*i) * math.pi
        ans_2 = a**2 + b**2 - 2*a*b * math.cos(sita)
        print(ans_2 ** 0.5)
        exit()

Solution (Python):
import math
from decimal import Decimal

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

HD = (1/2) - ((H+(M/60))/6)
MD = (1/2) - (M/30)

Ax = A*math.cos(HD*math.pi)
Ay = A*math.sin(HD*math.pi)
Bx = B*math.cos(MD*math.pi)
By = B*math.sin(MD*math.pi)

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

print(ans)

Solution (Python):
import numpy

A,B,H,M=map(int,input().split())
x=2*numpy.pi*(M/60)
y=2*numpy.pi*(H+M/60)/12

ans=A*A+B*B-2*A*B*numpy.cos(x-y)
print(ans**(1/2))

Solution (Python):
import math
from decimal import Decimal as dec

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

if __name__ == "__main__":
    main()

Solution (Python):
import math
A, B, H, M = map(int, input().split())
h_hand = H*30+M*0.5
m_hand = 6 * M
diff_hand = abs(h_hand - m_hand)
print((A**2+B**2-2*A*B*math.cos(math.radians(diff_hand)))**0.5)

Solution (Python):
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

a,b,h,m = map(float , input().split())
hd= h*30+m/2
md = m*6
d = abs(hd-md)
d= min(d, 360-d)
ans = (a*a+b*b-2*(a*b*(math.cos(d*math.pi/180))))
print('%.20lf'%math.sqrt(ans))

Solution (Python):
from decimal import Decimal as dec
import math

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

if __name__ == "__main__":
    main()

Solution (Python):
import math
a, b, h, m= map(int, input().split())
x = abs(30 * (h + m / 60) - 6 * m)
y = 360 - x
z = min(x, y)
c = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(z))
c = math.sqrt(c)
print(c)

Solution (Python):
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)

Solution (Python):
import math
a ,b, h, m = map(int, input().split())

arg = math.radians(((h*60+m)*360/(12*60))-((m*360)/60))

dist=math.sqrt(a**2+b**2-2*a*b*math.cos(arg))
print(dist)

Solution (Python):
import math
from decimal import Decimal as dec

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

if __name__ == "__main__":
    main()

Solution (Python):
import math
a,b,h,m = map(int, input().split())

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

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

Solution (Python):
a,b,h,m = list(map(int, input().split()))

h = (h*30) + (m * 0.5 )
m = m*6

s = abs(h-m)
if s >= 180:
    s  = 360 - s

import math 
cos = math.cos(math.radians(s))


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

Solution (Python):
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(math.dist((xh, yh), (xm, ym)))

Solution (Python):
import math
a,b,h,m =map(int, input().split())

angle = h / 12 + m / 60 / 12 - m / 60
rad = 2 * math.pi * angle
an = a*a + b*b -2*a*b*math.cos(rad)
ans = an**0.5

print(ans)

Solution (Python):
import math
a,b,h,m=[int(x) for x in input().split()]
theta=30*h-m*(11/2)
l=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(theta)))
print(l)

Solution (Python):
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)

Solution (Python):
import math
A,B,H,M = map(int, input().split())
H1=(360*H/12)+(30*M/60)
M1=360*M/60
o=abs(H1-M1)
c=math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(o)))
print(c)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
hour = complex(0, A)
minute = complex(0, B)
hourTheta = math.pi / 180 * (360 // 12 * (3 - H) - M / 2)
minuteTheta = math.pi / 180 * (360 // 60 * (15 - M))
hour *= complex(math.cos(hourTheta), math.sin(hourTheta))
minute *= complex(math.cos(minuteTheta), math.sin(minuteTheta))
print(abs(hour - minute))

Solution (Python):
import math
H = [0,0]
M = [0,0]
a, b, h, m =map(int,input().split())
mrad = -m * math.pi / 30
hrad = -(h + m/60 ) * math.pi / 6
H[0] = a * math.cos(hrad)
H[1] = a * math.sin(hrad)
M[0] = b * math.cos(mrad)
M[1] = b * math.sin(mrad)
ans = math.sqrt((H[0] -M[0])**2 + (H[1] -M[1])**2)
print(ans)

Solution (Python):
import math

a,b,h,m=map(int,input().strip().split())
minDeg=m*6.0
hourDeg=h*30.0+(m/12.0)*6.0
degDif=0.0
ans=0
if abs(minDeg-hourDeg)==180:
  ans=a+b
elif abs(minDeg-hourDeg)==90:
  ans=math.sqrt(a**2+b**2)
elif abs(minDeg-hourDeg)>180:
  degDif=360.0-(abs(minDeg-hourDeg))
  ans=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(degDif)))
elif abs(minDeg-hourDeg)<180:
  degDif=abs(minDeg-hourDeg)
  ans=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(degDif)))
print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split())

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

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

ans=cal(kakudo(h,m))
print(ans)

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

import math

def pos(k, l):
    r = math.radians(k)
    x = l * math.cos(r)
    y = l * math.sin(r)
    return(x,y)

def test():
    
    a,b,h,m = [int(i) for i in input().split()]
    hx, hy = pos(((h*60+m)%720)/2, a)
    mx, my = pos((m % 60)*6, b)
    return(math.sqrt((hx-mx)**2 + (hy-my)**2))


print(test())

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


s = M / 60
t = H + s
u = t / 12  

v = M / 60

w = abs(u-v) * 360

import math
cos = math.cos(math.radians(w))

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


print(ans)

Solution (Python):
import math
A, B, H, M = [int(_) for _ in input().split()]

radA = math.radians(H * 360 / 12 + M * 360 / 12 / 60)
radB = math.radians(M * 360 / 60)

xa = A * math.sin(radA)
ya = A * math.cos(radA)

xb = B * math.sin(radB)
yb = B * math.cos(radB)

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

Solution (Python):
import math

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

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

theta = abs(B_theta - A_theta)

cos = math.cos(math.radians(theta))

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

print(dist)

Solution (Python):
import math
i = list(map(int, input().split()))
angle_M=6*i[3]
angle_H=30*i[2]+0.5*i[3]
angle_ans=abs(angle_M-angle_H)

ans=i[0]**2+i[1]**2-(2*i[0]*i[1]*math.cos(math.radians(angle_ans)))
print(math.sqrt(ans))

Solution (Python):
import numpy as np
a, b, h, m = (int(i) for i in input().split())
theta = np.radians(30 * h + 0.5 * m)
phi = np.radians(6 * m)
ax = np.sin(theta) * a
ay = np.cos(theta) * a
bx = np.sin(phi) * b
by= np.cos(phi) * b
ans = np.sqrt((ax-bx)**2 + (ay-by)**2)
print(ans)

Solution (Python):

import glob
import math



REL_PATH = 'ABC\\168\\C'


TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

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

        d_a = 90 - (360 / 12 * H + 30 / 60 * M)
        d_b = 90 - 360 / 60 * M

        c_a = [A * math.cos(math.radians(d_a)), A * math.sin(math.radians(d_a))]
        c_b = [B * math.cos(math.radians(d_b)), B * math.sin(math.radians(d_b))]

        print(str(math.sqrt((c_a[0] - c_b[0]) ** 2 + (c_a[1] - c_b[1]) ** 2)))






solver = Solver(REL_PATH)
solver.exec_resolve()

Solution (Python):
import math

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

t = h*60+m
ang = 11*math.pi*t/360
l = (a**2+b**2-2*a*b*math.cos(ang))**0.5

print(l)

Solution (Python):
import math


def deg2rad(x):
    result = x / 360 * math.pi * 2
    return result


def rad2place(a, x):
    return a * math.cos(x), a * math.sin(x)


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

deg_m = 90 + (60 - m) / 60 * 360
rad_m = deg2rad(deg_m)
mx, my = rad2place(b, rad_m)

deg_h = 90 + ((12 - h) - m / 60) / 12 * 360
rad_h = deg2rad(deg_h)
hx, hy = rad2place(a, rad_h)

dx = hx - mx
dy = hy - my

ans = math.sqrt(dx**2 + dy**2)
print(ans)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
w1 = math.pi * H / 6 + math.pi * M / 360
w2 = math.pi * M / 30
rad = abs(w1 - w2)
if rad > math.pi:
    rad = 2 * math.pi - rad

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

Solution (Python):
import numpy as np
A, B, H, M = [int(i) for i in input().split(" ")]

T = H * 3600 + M * 60

oA = T / (12 * 3600)
oB = T / 3600
oA = (oA - int(oA)) * 2 * np.pi
oB = (oB - int(oB)) * 2 * np.pi




diff = np.abs(oA - oB)
if diff > np.pi:
  t = 2 * np.pi - diff
else:
  t = diff
print(np.sqrt(B**2 + A**2 - 2 * A * B * np.cos(t)))

Solution (Python):
import math
a,b,hour,min = map(int,input().split())

arad = math.radians(360*((hour+min/60)/12))
brad = math.radians(360*min/60)
p = (a*math.cos(arad),a*math.sin(arad))
q = (b*math.cos(brad),b*math.sin(brad))

print(math.dist(p,q))

Solution (Python):
import math
A,B,H,M = list(map(int,input().split(" ")))


Ha = (H * 360 / 12) + (30 * M/60)

Ma = M * 360 / 60

a = abs(Ha-Ma)

cosa = math.cos(math.radians(a))

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

print(ans)

Solution (Python):


import math

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

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

if abs(m_angle - h_angle) >= 180:
    theta = 360 - abs(m_angle - h_angle)
else:
    theta = abs(m_angle - h_angle)

if theta == 0:
    x = abs(a - b)
elif theta == 180:
    x = a + b
else:
    x2 = a**2 + b**2 - 2*a*b * math.cos(math.radians(theta))
    x = x2**0.5

print(x)

Solution (Python):
import sys
import math
sys.setrecursionlimit(1000000)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
LI = LI()
A = LI[0]
B = LI[1]
H = LI[2]
M = LI[3]
a = (60 * H + M) / 720 * 2 * math.pi
b = M / 60 * 2 * math.pi

theta = a - b
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
print(ans)

Solution (Python):
import math

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

H_angle  = (H*30)+ (M/60)*30 
M_angle  = (M/60)*360
ab_angle = abs(M_angle-H_angle)
C_2 = A**2 + B**2 -2*A*B*math.cos(math.radians(ab_angle))
print(math.sqrt(C_2))

Solution (Python):
from math import (pi,cos,sqrt)
A,B,H,M=map(int,input().split())
print(sqrt(A*A+B*B-2*A*B*cos(pi*(H/6+M/360-M/30))))

Solution (Python):
from math import cos, pi
a, b, h, m = map(int, input().split())
arg_a = 0.5*(60*h + m)
arg_b = 6*m
arg = max(arg_a,arg_b) - min(arg_a,arg_b)
if arg >= 180:
    arg = 360 - arg
cos_arg = cos(arg*pi/180)
dd = a**2 + b**2 - 2*a*b*cos_arg
print(dd**(1/2))

Solution (Python):
import math
a,b,h,m=map(int,input().split())
q=abs((h+m/60)/12-m/60)*360
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(q))))

Solution (Python):
import math
A,B,H,M = list(map(int,input().split()))

ang_h = (H + M/60)* 30
ang_m = M * 6
c = 0
ang = abs(ang_m - ang_h)
if ang >=180:
	ang = 360- ang
c = (A**2 + B**2 -2*A*B*math.cos(math.radians(ang)))**0.5

print(c)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
h = H * 30 + M * 0.5
m = M * 6
radius = abs(h-m)
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(radius)))
print(ans)

Solution (Python):
import math 


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

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




h_Theta=float(h*60+m)/720 * 2*math.pi

m_Theta=float(m)/60 * 2*math.pi


hx=a*math.cos(h_Theta)

hy=a*math.sin(h_Theta)

mx=b*math.cos(m_Theta)

my=b*math.sin(m_Theta)


dx=hx-mx

dy=hy-my


ans=math.sqrt(dx**2+dy**2)
print(ans)

Solution (Python):
import math
a,b,h,m=map(float,input().split())
angle=0
if(h*5<m):
    angle=(m/60*2*math.pi)-(h/12*2*math.pi+m/60*2*math.pi/12)
else:
    angle=(h/12*2*math.pi+m/60*2*math.pi/12)-(m/60*2*math.pi)
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(angle))
print(ans)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
h = h * 30 + (30*m/60)
m = m * 6
radius = abs(m-h)
ans = math.sqrt(b**2+a**2-2*a*b*math.cos(math.radians(radius)))
print(ans)

Solution (Python):
import math

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


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



test1 = pow(a, 2) + pow(b, 2)

test2 = 2 * a * b * math.cos(math.radians(angle))

ret = math.sqrt(test1 - test2)

print("{}".format(ret))

Solution (Python):
import numpy as np
A, B, H, M = map(int, input().split())
a = 30 * (H + M / 60)
b = 360 * (M / 60)
r = abs(a - b)
deg_ = min(r, 360 - r)
ans_ = A ** 2 + B ** 2 - 2 * A * B * np.cos(deg_ * np.pi / 180)
print("{:.021f}".format(np.sqrt(ans_)))

Solution (Python):
import math
a,b,h,m = map(int,input().split())

t = 2*math.pi*(m/60 - (h + m/60)/12)
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(t)))

Solution (Python):
import math


def main():

    a, b, h, m = map(int, input().split())
    kakub = 6.0 * m
    kakua = 30.0 * h + (30.0 * (m / 60.0))
    maxx = max(kakua, kakub)
    minn = min(kakua, kakub)

    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn
    else:
        aug = 180.0

    if aug == 180.0:
        ans = a + b
        print(ans)

    else:
        ans = (a ** 2.0) + (b ** 2.0) - ((2.0 * a * b) * math.cos(math.radians(aug)))
        print(math.sqrt(ans))


if __name__ == '__main__':
    main()

Solution (Python):
import math
a, b, h, m = map(int, input().split())
t = 2 * math.pi * (m / 60 - (h + m / 60) / 12)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(t)))

Solution (Python):
import math

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

tm = M / 60.0 * 2 * math.pi
mx = B * math.cos(tm)
my = B * math.sin(tm)

th = (H * 60.0 + M) / 720 * 2 * math.pi
hx = A * math.cos(th)
hy = A * math.sin(th)

dx = hx - mx
dy = hy - my

print(math.sqrt(dx * dx + dy * dy))

Solution (Python):
import math

A, B, H, M = map(int, input().split())
theta_1 = (H + M / 60) / 12 * (2 * math.pi)
theta_2 = M / 60 * (2 * math.pi)
print(math.sqrt((A * math.cos(theta_1) - B * math.cos(theta_2)) ** 2 + (A * math.sin(theta_1) - B * math.sin(theta_2)) ** 2))

Solution (Python):
import math
[A,B,H,M] = map(int,input().split())
angA = (H+M/60)*30*(math.pi/180)
angB = M*6*(math.pi/180)
ang = abs(angA - angB)



X = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(ang))
print (X)

Solution (Python):
import numpy as np
A, B, H, M = map(float, input().split())
tH = 2*np.pi*(H*60+M)/60/12
tM = 2*np.pi*M/60
t = tH - tM
l = np.sqrt(A*A + B*B - 2*A*B*np.cos(t))
print(l)

Solution (Python):
import math as mt
A,B,H,M = map(int, input().split())
if abs(30*H+0.5*M-6*M) >= 180:
  d = 360 - abs(30*H+0.5*M-6*M)
else:
  d = abs(30*H+0.5*M-6*M)
ans = mt.sqrt(A**2+B**2-2*A*B*mt.cos(mt.radians(d)))
print(ans)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
hrad = h * 30 + m * 0.5
mrad = m * 6
rad = hrad - mrad
if rad < 0:
    rad = -rad
else:
    if rad > 180:
        rad = 360 - rad
    else:
        pass
c = float((a**2 + b**2 - 2 * a * b * math.cos(math.radians(rad))) ** (0.5))
print(c)

Solution (Python):


"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()



def solve():
    a,b,h,m = invr()
    if True:
        if (h == 12): 
            h = 0
        if (m == 60): 
            m = 0
        hour_angle = 0.5 * (h * 60 + m) 
        minute_angle = 6 * m
        q = abs(hour_angle - minute_angle) 
        q = min(360 - q, q) * math.pi / 180
    print(math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * math.cos(q))))
                


 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 

def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

def power_two(n):
    if n == 1:
        return(True)
    sttr = str(n)
    len_str = len(sttr)
    sttr = list(sttr)
    num = 0
    if (len_str == 1 and sttr[len_str - 1] == '1'): 
        return(False)
    while (len_str != 1 or sttr[len_str - 1] != '1'):
        if ((ord(sttr[len_str - 1]) - ord('0')) % 2 == 1):
            return(False)
        j = 0; 
        for i in range(len_str):  
            num = num * 10 + (ord(sttr[i]) - ord('0')); 
            if (num < 2): 
                if (i != 0):  
                    sttr[j] = '0'
                    j += 1
                continue
  
            sttr[j] = chr((num // 2) + ord('0'))
            j += 1; 
            num = (num) - (num // 2) * 2
        len_str = j
    return(True)

def log_two(n): 
    return(math.log(n) / math.log(2))


        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Solution (Python):
import math
A,B,H,M = map(int,input().split())
time = H*60+M
theta1 = 2*math.pi*time/(12*60)
theta2 = 2*math.pi*time/60

ax,ay = A*math.cos(theta1),A*math.sin(theta1)
bx,by = B*math.cos(theta2),B*math.sin(theta2)

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

Solution (Python):
import math

a,b,h,m = map(int,input().split())
H = ((60*h + m) / 720)*360
M = 6*m
o = abs(H - M)
if o >= 180:
    o = 360 - o

rado = math.radians(o)

ans = (a**2 + b**2 - 2*a*b*math.cos(rado))**0.5
print(ans)

Solution (Python):
import sys
import math
def main():
    A,B,H,M=tuple(map(int,sys.stdin.readline().split()))
    t,p=math.pi*(60.0*H+M)/360.0,math.pi*M/30.0
    xa,ya=A*math.cos(t),A*math.sin(t)
    xb,yb=B*math.cos(p),B*math.sin(p)
    l=math.sqrt((xb-xa)**2+(yb-ya)**2)
    print(l)
if __name__=='__main__':main()

Solution (Python):
import math


def solve():
    A, B, H, M = map(int, input().split())
    theta = abs((H+(M/60))*30-M*6)
    x = abs(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(theta))))
    print(x)


if __name__ == '__main__':
    solve()

Solution (Python):
a, b, h, m = list(map(int, input().split()))
import math
 
h = math.pi*(h+m/60)/6
m = math.pi*m/30
 
s = abs(h-m)
 
print(math.sqrt(a**2 + b**2 -2*a*b*math.cos(s)))

Solution (Python):
a, b, h, m = list(map(int, input().split()))
import numpy as np

h_a = np.pi*(h+m/60)/6
m_a = np.pi*m/30

s = abs(h_a-m_a)

print(np.sqrt(a**2 + b**2 -2*a*b*np.cos(s)))