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 math
from decimal import Decimal
hour_len, minute_len, hour, minute = list(map(int, input().split()))

degree_hm = abs(((hour * 60 + minute) * 0.5) - (minute * 6))
rad_hm = math.radians(degree_hm) 
cos_hm = math.cos(rad_hm)

a_double = hour_len ** 2 + minute_len ** 2 - (2 * hour_len * minute_len * cos_hm)
ans = math.sqrt(a_double)
print( f"{ans:.20f}" )

Solution (Python):
import math
from decimal import Decimal
hour_len, minute_len, hour, minute = list(map(int, input().split()))

rad_h = math.radians( Decimal( (hour * 60 + minute) / 720 * 360 ) )
rad_m = math.radians( Decimal(minute / 60 * 360) )
cos_hm = math.cos( abs( Decimal(rad_h - rad_m) ) )

a_double = hour_len ** 2 + minute_len ** 2 - (2 * hour_len * minute_len * cos_hm)
ans = math.sqrt(a_double)
print( f"{ans:.20f}" )

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

a_y = ((h/12)*360+m/(60*12)*360)%360
b_y = ((m/60)*360)%360

from math import *

alpha = ((a_y - b_y)%360)*pi/180

ans = sqrt(a**2+b**2-2*a*b*cos(alpha))

print(ans)

Solution (Python):
import math

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

m_radians = 360 * m / 60
h_radians = 360 * ((h * 5 + 5 * m / 60) / 60)

cos_ab = math.cos(math.radians(h_radians-m_radians))
c = math.sqrt(a**2 + b**2 - 2*a*b*cos_ab)

print(c)

Solution (Python):
import math

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

M_deg = M / 60 * 360
H_deg = (H / 12 * 360) + (M_deg / 12)


deg = min(abs(H_deg - M_deg), abs(M_deg - H_deg))

rad = math.radians(deg)

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

print(ans)

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

import math
print((a**2+b**2-2*a*b*math.cos(math.radians((360*h/12+30*m/60)-360*m/60)))**(1/2))

Solution (Python):
import math
A, B, H, M = map(int, input().split())
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(30*H - 11*M/2)))
print(ans)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
if H >= 12:
    H -= 12
choperminute = 360/60 
tanperminute = 30/60 

tankaku = H*30 + tanperminute*M
chokaku = choperminute*M

if chokaku >= tankaku:
    angle = chokaku -tankaku
else:
    angle = tankaku - chokaku
    
if angle > 180:
    angle = 360 -angle
    
ansjyou = (A**2) + (B**2) - (2*A*B*math.cos(math.radians(angle)))
print(ansjyou**0.5)

Solution (Python):
A,B,H,M = map(int, input().split())
m = M/60*360
h = H/12*360+M/60*30
kakudo = (h-m)%360
import math
cos = math.cos(math.radians(kakudo))
print(math.sqrt(A*A+B*B-2*A*B*cos))

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

Solution (Python):
import math

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

ang = h * 30 - m * 5.5

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

print(ans)

Solution (Python):
import math

def main():
    A, B, H, M = map(int, input().split())
    h_angle = 30 * H + 0.5 * M
    if h_angle <= 90:
        h_angle = math.radians(90 - h_angle)
    else:
        h_angle = math.radians(360 - (h_angle - 90))

    m_angle = 6 * M
    if m_angle <= 90:
        m_angle = math.radians(90 - m_angle)
    else:
        m_angle = math.radians(360 - (m_angle - 90))

    h_x = A * math.cos(h_angle)
    h_y = A * math.sin(h_angle)
    m_x = B * math.cos(m_angle)
    m_y = B * math.sin(m_angle)
    print(math.sqrt(abs(h_x - m_x)**2 + abs(h_y - m_y)**2))

if __name__ == '__main__':
    main()

Solution (Python):
import math

def cal(H,M):

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

    if H_M > 180:
        H_M = 360 - H_M
    
    return H_M

def main():
    A, B, H, M = map(int,input().split())
    
    angle = cal(H,M)
    
    if angle == 180:
        print(A+B)
    
    else:
        print(math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(angle))))
              
main()

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

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

    
    HTheta = H/12 * 360 + 1/12 * (M/60) *  360
    MTheta = M/60 * 360
    
    Theta = abs(HTheta - MTheta) 
    
    if Theta == 180:
        print(A + B)
        return
    
    print(sqrt(A*A + B*B - 2*A*B*cos(radians(Theta))))

main()

Solution (Python):
import math

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

angle = (H*30 + 30*(M/60))-M*6
abs_angle = abs(angle)

if abs_angle >180:
  abs_angle = 360 - abs_angle

abs_angle = math.cos(math.radians(abs_angle))
ans_sqrt = A**2 + B**2 - 2*A*B*abs_angle

print(math.sqrt(ans_sqrt))

Solution (Python):
import math
import numpy as np
a,b,h,m = list(map(int, input().split()))
a_radian = math.radians(h * 30 + m / 2)
a_ = np.array([a * math.cos(a_radian), a * math.sin(a_radian)])

b_radian = math.radians(6 * m)
b_ = np.array([b * math.cos(b_radian), b * math.sin(b_radian)])

print(np.linalg.norm(a_ - b_))

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

x = H / 12 * 360 + M / 60 * 30
y = M / 60 * 360

ang = abs(y - x)
ans_2 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(ang))
ans = math.sqrt(ans_2)
print(ans)

Solution (Python):
import math

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

ang = h * 30 - m * 11/2

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

print(c)

Solution (Python):
import math

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

ang = abs(h * 30 - m * 11/2)

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

print(c)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
k = M / 60
if H == 0:
    H = 12
if M == 0:
    M = 60

H_d = ((H/12 * 60 + k*5)/60)*2*math.pi
M_d = (M/60)*2*math.pi
r = abs(H_d-M_d)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(r)))

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

arg=min(abs(30*h-5.5*m), 360-abs(30*h-5.5*m))

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

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

Solution (Python):
import math

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

ang = abs(h * 30 - m * 11/2)
angle = min(ang, 360-ang)

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

print(c)

Solution (Python):
from math import*

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

print((A*A+B*B-2*A*B*cos((M*11/360-H/6)*pi))**.5)

Solution (Python):
import math

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

print((A**2+B**2-2*A*B*math.cos(math.radians(6*M-30*(H+(M/60)))))**(1/2))

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

Solution (Python):
import math

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

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

dx = A * math.cos(h_theta) - B * math.cos(m_theta)
dy = A * math.sin(h_theta) - B * math.sin(m_theta)

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

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


if H == 0:
    H = 12
elif M == 0:
    M = 60
L = M / 5



N = min(abs(L - H), abs(H - L))

if L >= H:
    if M == 60:
        M = 0
    S = 360 * N / 12 - (0.5 * M)
else:
    S = 360 * N / 12 + (0.5 * M)


ANS = A**2 + B**2 - (2*A*B*math.cos(math.radians(S)))
ANS = math.sqrt(ANS)
print(ANS)

Solution (Python):

"""
Created on Sun Sep  6 12:21:24 2020

@author: liang
"""
import math
pi = 3.141592653589793238
h, m, H, M = map(int,input().split())

print(math.sqrt(h**2+m**2-2*h*m*math.cos(2*pi*(30*H-5.5*M)/360)))

Solution (Python):
import math

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

print((A**2+B**2-2*A*B*math.cos(math.radians(abs((H*60+M)/2-M*6))))**0.5)

Solution (Python):
import math

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

min = h * 60 + m
short = 0.5 * min
long = 6 * m

if abs(short - long) >= 180:
    deg = 360 - abs(short - long)

else:
    deg = abs(short - long)

coss = math.cos(math.radians(deg))
c = (a ** 2 + b ** 2 - 2 * a * b * coss) ** 0.5

print('{:.20f}'.format(c))

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

Solution (Python):
import math
a,b,h,m = [int(x) for x in input().split()]
p = math.pi
arg_h = 2 * p * h / 12 + m * p / 360
arg_m = 2 * p * m / 60
arg = abs(arg_h - arg_m)
c_2 = a**2 + b**2 - 2 * a * b *math.cos(arg)
c = math.sqrt(c_2)
print(c)

Solution (Python):


import math

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

s = 3600*h + 60*m
radh = ((s/(60*60*12))-int(s/(60*60*12)))*2*math.pi
radm = ((s/(60*60))-int(s/(60*60)))*2*math.pi

c = math.sqrt(a**2+b**2-2*a*b*math.cos(radh-radm))

print(c)

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

import math

H_angle =(M * math.pi) / 30
M_angle = (60 * H + M) * math.pi / 360

H_x, H_y = (A * math.cos(H_angle), A * math.sin(H_angle))
M_x, M_y = (B * math.cos(M_angle), B * math.sin(M_angle))

d = math.sqrt((H_x - M_x) ** 2 + (H_y - M_y) ** 2)
print(d)

Solution (Python):
import math
def main():
    a, b, h, m = map(int, input().split(" "))
    r1 = h*30 + m / 2
    r2 = 6 * m
    r3 = abs(r1-r2)
    print(math.sqrt(a **2 + b **2 -2*a*b*math.cos(math.radians(r3))))

if __name__ == "__main__":
    main()

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

Solution (Python):
import math
A,B,H,M=map(int,input().split())
C2=A**2+B**2-2*A*B*math.cos((30*H-11*M/2)/180*math.pi)
print(C2**(1/2))

Solution (Python):
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
theta = min(2*math.pi-abs(thetaA-thetaB), abs(thetaA-thetaB))
cosC = math.cos(theta)
ans = math.sqrt(A**2+B**2-2*A*B*cosC)
print(ans)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
sitaH = (H*60+M) / 720 * 2 * math.pi
sitaM =  M/60 * 2 * math.pi

posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)

delX = posXH - posXM
delY = posYH - posYM

d = (delX*delX + delY*delY)**(1/2)
print(d)

Solution (Python):
A,B,H,M=map(int,input().split())
kakudo=30*H+M/2-6*M
import math
a=(abs(A**2+B**2-2*A*B*math.cos(math.radians(kakudo))))
answer=a**(1/2)
print(answer)

Solution (Python):
import numpy as np
a,b,h,m = map(int,input().split())
pos1 = [b*np.sin(np.radians(6*m)),b*np.cos(np.radians(6*m))]
pos2 = [a*np.sin(np.radians(30*h+m*(360/(12*60)))),a*np.cos((np.radians(30*h+m*(360/(12*60)))))]
d = ((pos1[0]-pos2[0])**2+(pos1[1]-pos2[1])**2)**0.5
print(d)

Solution (Python):
import math

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

theta_tansin = 360 * H / 12 + 30 * M / 60
theta_chosin = 360 * M / 60

theta = abs(theta_tansin - theta_chosin)
theta = min(theta, 360 - theta)
theta = math.radians(theta)

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

print(C)

Solution (Python):
import math

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

ha = (h*60+m)/360 * math.pi
ma = m/30 * math.pi
sh, ch = math.sin(ha), math.cos(ha)
sm, cm = math.sin(ma), math.cos(ma)
print(((a*sh-b*sm)**2+(a*ch-b*cm)**2)**(1/2))

Solution (Python):
import math

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

thetaA = (math.pi * H / 6) + (math.pi * M / 360)
thetaB = (math.pi * M / 30)
Ax = A * math.cos(thetaA)
Ay = A * math.sin(thetaA)
Bx = B * math.cos(thetaB)
By = B * math.sin(thetaB)

X = Ax - Bx
Y = Ay - By

ans = (X ** 2 + Y ** 2) ** 0.5

print(ans)

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

total_minute = 60 * h + m

ax = a * math.cos(math.radians(360-(total_minute/2)+ 90))
ay = a * math.sin(math.radians(360-(total_minute/2)+ 90))
bx = b * math.cos(math.radians(360-(6*m) + 90))
by = b * math.sin(math.radians(360-(6*m) + 90))

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

print(kyori)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
V1 = 30
V2 = 30/60
v = 6
d = abs( (V1*H + V2*M) - v*M)
print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(d))))

Solution (Python):
import math

a, b, h, m = list(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())
V1 = 30
V2 = 30/60
v = 6
d = abs( (V1*H + V2*M) - v*M)
if d == 0:
  print(abs(A-B))
else:
  print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(d))))

Solution (Python):
import math
a, b, h, m = map(int,input().split())
ms = m//60
ma = m%60
h = h + ms
ha =h%12 + ma/60
rh = ha*math.pi/6
rm = ma*math.pi/30
x = math.cos(rh - rm)
ans = math.sqrt(a**2 + b**2 - 2*a*b*x)
print(ans)

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

import math

C = 360
degS = H*360/12 + M*30/60
degL = M*360/60
rad = (degS-degL)*math.pi / 180
ans = math.sqrt(A*A+B*B-2*A*B*math.cos(rad))
print(ans)

Solution (Python):
def resolve():
    A, B, H, M = list(map(int, input().split()))
    ath = ((H*60+M)/(12*60))*360
    bth = M/60*360
    diff = abs(ath - bth) if abs(ath - bth) < 180 else 360-abs(ath - bth)
    import math
    print(math.sqrt((A**2)+(B**2)-2*A*B*math.cos(2*math.pi*diff/360)))


if '__main__' == __name__:
    resolve()

Solution (Python):
import math

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

rad_h = (h + m / 60) / 12
rad_m = m / 60


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


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

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

Solution (Python):


import math


def solve(A: int, B: int, H: int, M: int):
    ra = (H + M / 60.0) / 12.0 * 2.0 * math.pi
    rb = M / 60.0 * 2.0 * math.pi
    xa = A * math.cos(ra)
    ya = A * math.sin(ra)
    xb = B * math.cos(rb)
    yb = B * math.sin(rb)
    answer = math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2)
    return answer


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


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

h = (H/12 + (M/60)/12) * 360
m = (M/60) * 360
r = math.radians(h - m)
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(r))

print(ans)

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

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

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

Solution (Python):
a, b, h, m = map(int,input().split())
angle = 30*h - 5.5*m
if angle == 0:
  print(abs(b-a))
  exit()

import math
ans = (a*a + b*b - 2*a*b*math.cos(math.radians(angle)))**0.5
print(ans)

Solution (Python):
a, b, h, m = map(int,input().split())
angle = 30*h - 5.5*m

import math
ans = (a*a + b*b - 2*a*b*math.cos(math.radians(angle)))**0.5
print(ans)

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


f=h / 12 * 360 - m / 60 * 360 + m / 60 / 12 * 360


theta=math.radians(f)
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(theta)))

Solution (Python):
import math
a, b, h, m = [int(i) for i in input().split()]
theta = math.radians(h / 12 * 360 - m / 60 * 360 + m / 60 / 12 * 360)
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(theta)))

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

a, b, h, m = map(int, input().split())
angle = radians(h*30 + m / 2- m*6)
print(sqrt(a**2 + b**2 - 2*a*b*cos(angle)))

Solution (Python):
import numpy as np

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

def get_angle(h,m):
    long_angle=2*np.pi*m/60
    short_angle=2*np.pi*h/12+(2*np.pi/12)*m/60
    big_angle=max(long_angle,short_angle)
    small_angle = min(long_angle, short_angle)
    angle=min(big_angle-small_angle,2*np.pi-big_angle+small_angle)
    return angle

def yogen(a,b,theta):
    ans=a**2+b**2-2*a*b*np.cos(theta)
    return ans**0.5

print(yogen(a,b,get_angle(h,m)))

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

Solution (Python):
import math
 
A,B,H,M = map(int,input().split())
 
degree = 0
minute = 6*M
hour=30*H+0.5*M
if abs(minute-hour)>=180:
  degree = 360-abs(minute-hour)
else :
  degree = abs(minute-hour)



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

Solution (Python):
import math
A, B, H, M =map(int, input().split())
Hs = H*30 + M*0.5
Ms = 6*M
shita = Hs-Ms
shita = abs(shita)
if  shita >= 180:
    shita = 360 - shita
shita = math.radians(shita)
C = A*A + B*B - 2*A*B*(math.cos(shita))
print (math.sqrt(C))

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


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

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

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

import math
ans = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(360*(H/12-M/60+1/60*1/12*M))))



print(ans)

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


print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(5.5 * (H * 60 + M) * math.pi / 180 )))

Solution (Python):

import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 

from math import *
 
def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi
 
 
def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans
 
def lcm(a, b): return a * b // gcd(a, b)
 
 
def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

a, b, h, m = map(int, input().split())
radians = pi * 2 * (h / 12 + (m / 60) / 12 - m / 60)
dist = a * a + b * b - (2 * a * b) * cos(radians);
print(sqrt(dist))

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

ax = a*math.cos(math.radians(90-360/12*(h+m/60)))
ay = a*math.sin(math.radians(90-360/12*(h+m/60)))

bx = b*math.cos(math.radians(90-360/60*m))
by = b*math.sin(math.radians(90-360/60*m))

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

Solution (Python):
from math import cos,pi

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

rad = abs(m * pi / 30 - (h * 60 + m) * pi / 360)
ans = a ** 2 + b ** 2 - 2 * a * b * cos(rad)
print(ans ** 0.5)

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

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

angleH = radians(90 - H / 12 * 360 - M / 60 * 30)
angleM = radians(90 - M / 60 * 360)
Hx, Hy = A * cos(angleH), A * sin(angleH)
Mx, My = B * cos(angleM), B * sin(angleM)

print(((Hx - Mx)**2 + (Hy - My)**2)**(0.5))

Solution (Python):
import math
A, B, H, M = map(int, input().split())
 
X, Y = A*math.cos(math.pi*(60*H+M)/360), -A*math.sin(math.pi*(60*H+M)/360)
x, y = B*math.cos(math.pi*M/30), -B*math.sin(math.pi*M/30)
 
print(math.sqrt((X-x)**2+(Y-y)**2))

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


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

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):
import math

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

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

if degree >= 180:
    degree = 360 - degree

radians = math.pi*degree/180
length = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(radians))
print(length)

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(' '))
deg = abs(30 * H + 0.5 * M - 6 * M)
if deg > 180:
    deg = 360 - deg
deg = math.radians(deg)
print(math.sqrt((B - A * math.cos(deg)) ** 2 + (A * math.sin(deg)) ** 2))

Solution (Python):
A,B,H,M = map(int, input().split())
import math
h = ((H*60+M)/720)*2*math.pi
m = (M/60)*2*math.pi
s = A*math.cos(h)-B*math.cos(m)
t = A*math.sin(h)-B*math.sin(m)
print((s**2 + t**2)**0.5)

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

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

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

print(ans)

Solution (Python):
import math
def rad(a):
    return a*2*math.pi

A,B,H,M = map(int, input().split())
M /= 60.0
H = (H + M)/12;
H = rad(H)
M = rad(M)
ans = A*A+B*B-2*A*B*math.cos(H-M)
ans = math.sqrt(ans)
print(ans)

Solution (Python):
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)
        
    x_2 = a**2  + b**2 - 2*a*b*cos(radians(theta))
    print(x_2 ** 0.5)
    
main()

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

Solution (Python):

A, B, H, M= map(int,input().split())
import math
theta_S=-(30*H+(1/2)*M)+90
theta_L=-(6*M)+90
S_x=A*math.cos(math.radians(theta_S))
S_y=A*math.sin(math.radians(theta_S))
L_x=B*math.cos(math.radians(theta_L))
L_y=B*math.sin(math.radians(theta_L))
distance=((S_x-L_x)**2+(S_y-L_y)**2)**0.5
print(distance)

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

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

l = sqrt(a**2 + b**2 - 2*a*b*cos(abs(pi*h/6 + pi*m/360 - pi*m/30)))

print(l)

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

h_rad = math.radians((30 * (H + M / 60)))
m_rad = math.radians(6 * M)
diff = abs(h_rad - m_rad)

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

print(ans)

Solution (Python):
import math

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

minute = 60 * h + m
argA = minute / 720 * 2 * math.pi
argB = minute / 60 * 2 * math.pi
a_x = a * math.cos(argA)
a_y = a * math.sin(argA)
b_x = b * math.cos(argB)
b_y = b * math.sin(argB)
d = math.sqrt((a_x - b_x) ** 2 + (a_y - b_y) ** 2)

print(d)

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

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

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

SP_HOUR =  360 / (12 * 60)
SP_MIN = 360 / 60

angle = (H * 60 + M) * SP_HOUR - M * SP_MIN
if angle < 0:
    angle += 360






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

print(math.sqrt(ans_squ))

Solution (Python):
import math
A, B, H, M = map(int, input().split())
D = [(30*H) + (0.5*M), 6*M]
N = max(D) - min(D)
C = math.cos(math.radians(N))
sans = (A**2 + B**2) - (2*A*B*C)
ans = math.sqrt(sans)
print(ans)

Solution (Python):
import math
A, B, H, M = map(int,input().split())
a = (((H + M / 60) * 2 * math.pi) / 12) - ((M * 2 * math.pi) / 60)
b = (A ** 2 + B ** 2 - 2 * A * B * math.cos(a)) ** 0.5
print(b)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
D = [(30*H) + (0.5*M), 6*M]
N = max(D) - min(D)
C = math.cos(math.radians(N))
sans = (A**2 + B**2) - (2*A*B*C)
ans = math.sqrt(sans)
print(ans)

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

Solution (Python):
import math
A, B, H, M = map(int, input().split())
h = 360 / 12 * H + 0.5 * M
m = 6 * M
hm = abs(h - m)
if hm > 180:
    hm = 360 - hm
rad = math.radians(hm)
ans = A*A + B*B - 2*A*B*math.cos(rad)
print(ans**0.5)

Solution (Python):
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)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

Solution (Python):
import math
A,B,H,M=map(int,input().split())
b=30*H+30*(M/60)
c=6*M
d=math.fabs(b-c)
d=math.radians(d)
f=0

f=A**2+B**2-2*A*B*(math.cos(d))
print(math.fabs(math.sqrt(f)))

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

Solution (Python):
import math
rad = math.pi/180

A, B, H, M = map(int, input().split())
x = 6*M*rad
y = (60*H + M) * 0.5 * rad

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

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

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


a = (H/12+M/720) * 360
b = M/60 * 360

a = a-b
if a > 180:
    a = 360 - a
    

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

Solution (Python):
import math

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

rad1 = (2 * math.pi) * ((h * 60 + m) / 720)
rad2 = (2 * math.pi) * (m / 60)
x = abs(rad2 - rad1)
ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(x))
print(ans)

Solution (Python):
import math
from decimal import Decimal
A, B, H, M = map(int, input().split())
theta = abs(11/2*M - 30*H)
rad = math.radians(theta)
cos = Decimal(math.cos(rad))
ans = math.sqrt(A**2 + B**2 - 2 * A * B * cos)
print("{:.020f}".format(ans))

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

import numpy as np
theta_h=2*np.pi*(H/12 + M/720)
theta_m=2*np.pi*M/60
theta=min((max(theta_h, theta_m)-min(theta_h, theta_m)), 2*np.pi-(max(theta_h, theta_m)-min(theta_h, theta_m)))
print(np.sqrt(A**2 + B**2 - 2*np.cos(theta)*A*B))

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

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

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

Solution (Python):



def main():
    from math import cos
    from math import pi
    from math import sqrt
    import sys
    input = sys.stdin.readline

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

    
    
    
    hour = (60 * h + m) / 720 * 2 * pi
    minute = m / 60 * 2 * pi
    angle = abs(hour - minute)

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


if __name__ == '__main__':
    main()

Solution (Python):
import math
a, b, h, m = [int(x) for x in input().split(' ')]
print((a**2 + b**2 - 2 * a * b * math.cos(math.radians(h * 330 + m * 5.5)))**0.5)

Solution (Python):
from math import *
a, b, h, m = [int(_) for _ in input().split()]
print((a**2 + b**2 - 2*a*b * cos(radians(h*330 + m*5.5))) ** 0.5)

Solution (Python):
import math

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

x = A**2+B**2-2*A*B*math.cos(th)
result = math.sqrt(x)
print(result)

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

Solution (Python):
import math
A,B,H,M= map(int,input().split())
kd_a=0.5*(M+60*H)
kd_b=6*M

rad=math.radians(kd_a-kd_b)

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