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

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

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

Solution (Python):
import math

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

hTheta = math.pi * (60 * H + M) / 360
mTheta = math.pi * M / 30

delta = hTheta - mTheta

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

Solution (Python):
import math
jishin, hunshin, hour, minute = map(float, input().split())

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

kyori = math.sqrt((x_ji - x_hun) ** 2 + (y_ji - y_hun) ** 2)
print(kyori)

Solution (Python):
import math

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

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

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

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


m = 6*M

h = (H * 30) + ((30/60)*M)

kakudo = min(360 - abs(m - h), abs(h - m))
kakudo_a = math.radians(kakudo)
cos_x = math.cos(kakudo_a)
 
c = A**2 + B**2 - 2*A*B*cos_x
print(math.sqrt(c))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
ca = (h/6 + m/360)*math.pi
cb = (m/30)*math.pi

c = (ca - cb)
l = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(c))
print(l)

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

A_ang = (60*H+M)*math.pi/ 360
B_ang = M*math.pi / 30

X_A = A*math.sin(A_ang)
Y_A = A*math.cos(A_ang)

X_B = B*math.sin(B_ang)
Y_B = B*math.cos(B_ang)

X_D = X_A - X_B
Y_D = Y_A - Y_B

ans = math.sqrt(X_D*X_D + Y_D*Y_D)

print(ans)

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


def main():
    A, B, H, M = map(int, input().split())
    import math
    rb = math.pi * 2 * 6*M / 360
    ra = math.pi * 2 * (30*H + 0.5*M) / 360
    ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(ra-rb))
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math

def get_distance(hl,ml,h,m):
    (hx,hy) =  get_hx(hl,h,m)
    (mx,my) = get_mx(ml,m)
    return _get_distance(hx,hy,mx,my)

def _get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

def get_hx(length,time, m):
    radius = math.radians( 360 - ( (time * 30) + ( 30 *(m/60))))
    
    x = length * math.cos(radius)
    y = length * math.sin(radius)
    return (x,y)

def get_mx(length,time):
    r= 360 - (time * 6)
    radius = math.radians(r)
    
    x = length * math.cos(radius)
    y = length * math.sin(radius)
    return (x,y)


if __name__ == '__main__':

    n=int(1)
    string_list=[input() for i in range(n)]
    
    
    l =  string_list[0].split(" ")
    hl = int(l[0])
    ml =int(l[1])
    h=int(l[2]) 
    m=int(l[3])

    d = get_distance

    d = get_distance(hl,ml,h,m)
    print(d)

Solution (Python):
import math

class Watch():
    """
    This is a class to calculate angle and distance between two hands.
    
    Attributes:
        length_of_hour_hand(int): Length of the hour hand.
        length_of_minute_hand(int): Length of the minute hand.
        hours(int): Hours.
        minutes(int): Minutes.
    """

    def __init__(self, length_of_hour_hand, length_of_minute_hand,
                 hours, minutes):
        """
        The constructor for Watch class.

        Attributes:
            length_of_hour_hand(int): Length of the hour hand.
            length_of_minute_hand(int): Length of the minute hand.
            hours(int): Hours.
            minutes(int): Minutes.
            angle_between_two_hands(float): 
                Angle between the hour hand and the minute one.
            distance_between_two_hands(float): 
                Distance between the tip of hour hand and 
                that of minute one.
        """
        self.length_of_hour_hand = length_of_hour_hand
        self.length_of_minute_hand = length_of_minute_hand
        self.hours = hours
        self.minutes = minutes
        self.angle_between_two_hands = None
        self.distance_between_two_hands = None

    def calculate_angle_between_two_hands(self):
        """
        Calculate angle between the hour hand and the minute one.
        """

        
        degrees_of_hour_hand = (((self.hours + self.minutes/60.)/12.)
                               *2.*math.pi)
        
        degrees_of_minute_hand = (self.minutes/60.)*2.*math.pi
        
        
        angle_between_two_hands = (degrees_of_hour_hand
                                   - degrees_of_minute_hand)
        
        self.angle_between_two_hands = angle_between_two_hands
    
    def calculate_distance_between_two_hands(self):
        """
        Calculate distance between the tip of hour hand and 
        that of minute hand.
        """                          

        self.distance_between_two_hands = math.sqrt(
            self.length_of_hour_hand**2 + self.length_of_minute_hand**2
            - 2*self.length_of_hour_hand*self.length_of_minute_hand
            *math.cos(self.angle_between_two_hands))



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

watch = Watch(A, B, H, M)
watch.calculate_angle_between_two_hands()
watch.calculate_distance_between_two_hands()
print(watch.distance_between_two_hands)

Solution (Python):
A,B,H,M = map(int, input().split())
import math
Hrad = H*math.pi*2/12 + M*math.pi*2/(60*12)
Mrad = M*math.pi*2/60
theta = abs(Hrad - Mrad)
print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(theta)))

Solution (Python):
from math import sin, cos, pi, sqrt
a, b, h, m = (int(i) for i in input().split())
alpha, beta = 2*pi/12*h + 2*pi/12/60*m, 2*pi/60*m
ax, ay = a*sin(alpha), a*cos(alpha)
bx, by = b*sin(beta), b*cos(beta)
print(sqrt((ax - bx)**2 + (ay - by)**2))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
angle_m = m * 6
angle_h = h * 30 + m / 2
angle = abs(angle_h - angle_m)
angle = min(angle, 360 - angle)
angle *= math.pi / 180
dist = math.sqrt(a*a + b*b - 2*a*b*math.cos(angle))

print(dist)

Solution (Python):
import math
def main():
    line = [int(i) for i in input().split(' ')]
    A, B, H, M = line[0], line[1], line[2], line[3]
    ang = math.fabs(((H+M/60) / 12 * 360) - (M / 60 * 360))
    angle = min(ang, 360-ang)
    ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(angle)))
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
import math

if __name__ == '__main__':
    '''
    A: 時針の長さ
    B: 分針の長さ
    H: 何時
    M: 何分
    '''
    A, B, H, M = map(int, input().split())

    deg = (H * 30 + M * 0.5) - (360 / 60 * M)

    if deg <= 180:
        pass
    else:
        deg = 360 - deg

    rad = deg * math.pi / 180

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

Solution (Python):
import numpy as np
A, B, H, M= map(float,input().split())

thOne=-1.*np.pi/6.
thTwo=-1.*np.pi/30.

Hx=np.cos(thOne*H+thOne/60*M)*A
Hy=np.sin(thOne*H+thOne/60*M)*A
Mx=np.cos(thTwo*M)*B
My=np.sin(thTwo*M)*B



print(np.sqrt((Hx-Mx)**2+(Hy-My)**2))

Solution (Python):
import math

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

c = (h * 60 * 0.5) + (m * 0.5)
d = m * 6

if c > d:
  e = c - d
else:
  e = d - c

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

Solution (Python):
import cmath
A,B,H,M = map(int,input().split())
short_hand=A*cmath.exp(1j*cmath.pi*(H/6+M/360))
long_hand =B*cmath.exp(1j*cmath.pi*(M/30))
print(abs(short_hand-long_hand))

Solution (Python):
import math

def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
def is_prime(n,k):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            res=i
            break
    return res
def inp():
    ls=list(map(int,input().split()))
    return ls
a,b,h,m=map(int,input().split())
hangl=0.5*(60*h+m)
mangl=6*m
angl=abs(mangl-hangl)
if angl>180:
    angl=360-angl
c=math.sqrt(a*a+b*b-2*a*b*math.cos((angl*math.pi)/180))
print(c)

Solution (Python):
import math

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




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

rad = abs(rad_h - rad_m)

if rad == 0:
    C = abs(A - B)
elif math.pi <= rad:
    rad = 2 * math.pi - rad

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

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

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

m_theta = (M/60.0)*2*pi
h_theta = 1/12.0*(H + M/60.0) * 2* pi
mh_theta = abs(m_theta - h_theta)

x = A**2 + B**2 - 2*A*B*cos(mh_theta)
x = sqrt(x)
print(x)

Solution (Python):
def resolve():
    import math
    A, B, H, M = map(int, input().split())
    Hradian = math.radians(30*H+M/2)
    Mradian = math.radians(6*M)
    Hx, Hy = -1*A*math.sin(Hradian), A*math.cos(Hradian)
    Mx, My = -1*B*math.sin(Mradian), B*math.cos(Mradian)
    ans = ((Hx-Mx)**2 + (Hy-My)**2)**0.5
    print(ans)
resolve()

Solution (Python):
import math
A,B,H,M = map(int,input().split())
m = H*60 + M
r_a = m / 720
r_b = m / 60
r = abs(r_a - r_b)
if r > 1:
  r = abs(r - int(r))
if r > 0.5:
  r = abs(1 - r)
c = math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(360*r)))
print(c)

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

def deg2rad(deg):
  return deg * math.pi / 180.0

th1 = deg2rad(M * 360.0 / 60)
th2 = deg2rad(((H % 12) + M / 60.0) * 360.0 / 12)

c2 = A**2 + B**2 - 2.0 * A * B * math.cos(th1 - th2)

print(math.sqrt(c2))

Solution (Python):
import math

a,b,h,m = tuple([int(x) for x in input().split(' ')])
m_kakudo = 2 * math.pi * (m / 60)
h_kakudo = 2 * math.pi * (h / 12) + m_kakudo / 12
kakudo = abs(m_kakudo-h_kakudo)
if kakudo >= (math.pi):
    kakudo = math.pi - (kakudo - math.pi)
ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(kakudo))
print(ans)

Solution (Python):


from math import cos, sin, hypot, pi

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

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

hp = [A * cos(h_theta), A * sin(h_theta)]
mp = [B * cos(m_theta), B * sin(m_theta)]

print(hypot(hp[0] - mp[0], hp[1] - mp[1]))

Solution (Python):
import math
A,B,H,M = list(map(int,input().split()))
H_Angle = (H/12 + M/(12*60)) * 360
M_Angle = M/60 * 360
HM_Angle = abs(H_Angle - M_Angle)
Cos = math.cos(math.radians(HM_Angle))
LL = A**2 + B**2 - 2*A*B*Cos
L= math.sqrt(LL)
print(L)

Solution (Python):
import numpy as np

A,B,H,M = map(int,input().split())
m = H * 60 + M
short_ang = m * 0.5
long_ang = m * 6.
Ang = abs(long_ang - short_ang)
C = np.sqrt(A ** 2 + B ** 2 - 2*A*B*np.cos(Ang*np.pi/180))
print(C)

Solution (Python):
import math

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

jihun = 60*h + m


kakua= 2* math.pi * jihun/720
kakub =2* math.pi * m/60



ax = a * math.cos(kakua)
ay = a * math.sin(kakua)



bx = b * math.cos(kakub)
by = b * math.sin(kakub)


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

print(ans)

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

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

Solution (Python):


import math

numbers = input().split(" ")

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

rad1 = math.pi * 2.0 / 12.0 * (h + m / 60.0) 
rad2 = math.pi * 2.0 * (h + m / 60.0) 


rad1 = rad1 % (2 *math.pi)
rad2 = rad2 % (2 *math.pi)

rad = math.fabs(rad1 - rad2)


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

print(c)

Solution (Python):
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

r = h*30+m*0.5 - m*6
r = min(r, 360-r)
ans = (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(r))) ** 0.5
print(ans)

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

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

m = H * 60 + M
h = 360.0 / 60.0 * (m % 60)
mi = 360.0 / 720.0 * (m % 720)
arg = abs(h - mi)

print(sqrt(A**2 + B**2 - 2.0 * A * B * cos(radians(arg))))

Solution (Python):
import math

(a, b, h, m) = tuple(map(int, input().split()))
minutes = h * 60 + m
h_deg = (minutes  / (12 * 60)) * 2 * math.pi
m_deg = (minutes  / 60) * 2 * math.pi
h_x = a * math.cos(h_deg)
h_y = a * math.sin(h_deg)
m_x = b * math.cos(m_deg)
m_y = b * math.sin(m_deg)
print(math.sqrt((h_x - m_x) * (h_x - m_x) + (h_y - m_y) * (h_y - m_y)))

Solution (Python):
import math

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

angle = abs(h*30+m/2 - m*6)
print(format(math.sqrt((a**2 + b**2) - (2*a*b*math.cos((angle*math.pi)/180))), '.18f'))

Solution (Python):
import math
import numpy

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

RA = math.radians(360 * H / 12 + 30 * M / 60)
RB = math.radians(360 * M / 60)

XA = A*math.cos(RA)
YA = A * math.sin(RA)

XB = B*math.cos(RB)
YB = B*math.sin(RB)

XYA = numpy.array([XA, YA])
XYB = numpy.array([XB, YB])
U = XYB - XYA
print(numpy.linalg.norm(U))

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

hangle = 360*(h/12+m/(60*12))
mangle = 360*m/60
hm = math.radians(abs(hangle-mangle))

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

print(ans)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
     
mr = 6*m
hr = 360*(h/12+m/720)
r = math.radians(abs(mr-hr))
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())

mr = 6*m
hr = 360*(h/12+m/720)
r = math.radians(abs(mr-hr))
ans = math.sqrt((a**2)+(b**2)-2*a*b*math.cos(r))
print(ans)

Solution (Python):
import numpy as np

A, B, H, M = map(int, input().split())
a = np.array([[0., float(A)]])
b = np.array([[0., float(B)]])
hour_rad = -np.deg2rad(30.*H + 30. * float(M / 60))
hour_rotate = np.array([[np.cos(hour_rad), -np.sin(hour_rad)],
                        [np.sin(hour_rad), np.cos(hour_rad)]])
minute_rad = -np.deg2rad(6.*M)
minute_rotate = np.array([[np.cos(minute_rad), -np.sin(minute_rad)],
                        [np.sin(minute_rad), np.cos(minute_rad)]])
diff = np.dot(hour_rotate, a.T) - np.dot(minute_rotate, b.T)
d_pow = np.sum(diff ** 2)
d = np.sqrt(d_pow) if d_pow > 0. else 0.
print(d)

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

Solution (Python):
import math
s = input().split()
hour_len = int(s[0])
min_len = int(s[1])
hour = int(s[2])
minutes = int(s[3])
total_minutes = hour * 60 + minutes

hour_rad_per_one_minute = 360 / (12 * 60)

min_rad_per_one_minute = 360 / 60

hour_rad = hour_rad_per_one_minute * total_minutes
min_rad = min_rad_per_one_minute * minutes

rad = abs(hour_rad - min_rad)

length_2 = hour_len ** 2 + min_len ** 2 - 2 * hour_len * min_len * math.cos(math.radians(rad))

length = math.sqrt(length_2)
print(length)

Solution (Python):
import math
a,b,h,m = str(input()).split()
_a = int(a)
_b = int(b)
arc_m = int(m)/60.0
arc_h = int(h)/12.0 + arc_m/12
_cos = math.cos(abs(arc_m - arc_h)*2*math.pi)
print(math.sqrt(_a**2 + _b**2 - 2*_a*_b*_cos))

Solution (Python):
import math

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

minuteAngle = math.radians(M*6)

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

angleC = abs(hourAngle - minuteAngle)

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

Solution (Python):
import math

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

minuteAngle = math.radians(M * 6)

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

angleC = abs(hourAngle - minuteAngle)

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

Solution (Python):
import math
A,B,H,M=map(int,input().split())
H=5*H+5*M/60
theta=6*abs(H-M) 
if theta>180:
    theta=360-theta
C=math.sqrt(A**2+B**2-2*A*B*(math.cos(math.radians(theta))))
print(C)

Solution (Python):
import math

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

PI = math.pi

A_rad = PI * (60*H + M)/360
B_rad = PI * M/30

cosine = math.cos(A_rad - B_rad)

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

print(ans)

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

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

Solution (Python):

jishin, funshin, hji, mfun = map(int, input().split())

jiDegree = hji * 360 / 12 + mfun * 360 /(12*60)
funDegree = mfun * 360 / 60

deg = max(jiDegree, funDegree) - min(jiDegree, funDegree)
if deg > 180:
    deg = 360 - deg

from math import cos, radians, sqrt

len2 = jishin**2 + funshin**2 - 2*jishin*funshin*cos(radians(deg))

print(sqrt(len2))

Solution (Python):
import math
a,b,h,m = map(int, input().split())
w = abs((30*h+0.5*m - 6*m))
if w > 180:
  w = 360 - w
A = a
B = b
A *= a
B *= b
l = round(A + B - 2*a*b*math.cos(math.radians(w)),11)
print(l**0.5)

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

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




ra = -1
a_ra = 30 * H + (30/60) * M
b_ra = 6 * M
if a_ra < b_ra:
  ra = b_ra - a_ra
else:
  ra = a_ra - b_ra
  
if ra > 180:
  ra = 360 - ra

import math
ans = (A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(ra))) ** 0.5

print(ans)

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


def main():
    a, b, h, m = map(int, readline().rstrip().split())
    pi = math.pi
    aArg = (60 * h + m) * pi / 360
    bArg = m * pi / 30
    print(((a * math.cos(aArg) - b * math.cos(bArg)) ** 2 +
           (a * math.sin(aArg) - b * math.sin(bArg)) ** 2) ** 0.5)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

a,b,h,m = imap()

r1 = 2*PI * (h/12 + m/60/12)
r2 = 2*PI * (m/60)

z1 = a * complex(cos(r1), sin(r1))
z2 = b * complex(cos(r2), sin(r2))

ans = abs(z1 - z2)
print(ans)

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




min = (60 * h) + m
ang0 = (min * 5.5) % 360

if ang0 <= 180:
    ang = ang0
else:
    ang = 360 - ang0

import math
cos_ang = math.cos(math.radians(ang))

x = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * cos_ang))

print(x)

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

a = int(a)
b = int(b)
h = int(h)
m = int(m)




min = (60 * h) + m
ang0 = (min * 5.5) % 360

if ang0 <= 180:
    ang = ang0
else:
    ang = 360 - ang0

import math
cos_ang = math.cos(math.radians(ang))

x = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * cos_ang))

print(x)

Solution (Python):
from math import pi, cos, sin
a, b, h, m = list(map(int, input().split()))
ang1 = h * pi / 6 + m * pi / 360
ang2 = m * pi / 30
vec1 = (a * cos(ang1), a * sin(ang1))
vec2 = (b * cos(ang2), b * sin(ang2))
vec3 = (vec2[0] - vec1[0], vec2[1] - vec1[1])
size = (vec3[0] * vec3[0] + vec3[1] * vec3[1]) ** 0.5
print(size)

Solution (Python):
d=input()
abhm=d.split()

import math
import numpy as np
A = int(abhm[0])
B = int(abhm[1])
H = int(abhm[2])
M = int(abhm[3])
c_2=A**2+B**2-2*A*B*math.cos(math.radians((M*0.5+H*30)-M*6))
C=np.sqrt(c_2)
print(C)

Solution (Python):
import math

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

long_rad = ((h + m / 60) * math.pi) / 6
short_rad = (m * math.pi) / 30

rad = abs(long_rad - short_rad)

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())
deg=abs(h*30+m*0.5)-(m*6)
if deg>=180:
  deg=360-deg
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*deg/180))
print(c)

Solution (Python):

import math
a, b, h, m = map(int, input().split())
a_rad = h*math.pi/6 + m*math.pi/360
b_rad = m*math.pi/30
print((a**2 + b**2 -2*a*b*math.cos(a_rad-b_rad))**(1/2))

Solution (Python):
import math

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

c = abs((h + m / 60) / 12 - m / 60) * 360
result = math.sqrt((a ** 2 + b ** 2) - (2 * a * b) * math.cos(math.radians(c)))
print(result)

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

Solution (Python):
import math

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

H %= 12

deg = abs(H*30 - M*5.5)
if deg >= 180:
    deg = 360 - deg

rad = deg*math.pi / 180

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

Solution (Python):
import math as m

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

def vector(theta, magnitude):
    x = magnitude * m.cos(theta)
    y = magnitude * m.sin(theta)
    return x, y

u = vector((H+M/60)/12 * 2*m.pi, A)
v = vector(M/60 * 2*m.pi, B)

print(m.dist(u, v))

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

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

def alpha(M,H):
    return (M/H)*2*pi

def point(alpha,B):
    return [B*cos(alpha),B*sin(alpha)]

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

a1 = alpha(M,60)
a2 = alpha(H,12)+alpha(M/60,12)

p1 = point(a1,B)
p2 = point(a2,A)

print(sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2))

Solution (Python):
import math

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

c1 = 2*math.pi*(H/12 + 1/12*(M/60))
c2 = 2*math.pi*(M/60)

out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(c1-c2))
print(out)

Solution (Python):


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

import math
th = (60*h + m)/720*360
tm = (m/60)*360

xa,ya = a*math.cos(math.radians(th)),a*math.sin(math.radians(th))

xb,yb = b*math.cos(math.radians(tm)),b*math.sin(math.radians(tm))

dx,dy = xa-xb,ya-yb
c = math.sqrt(dx**2+dy**2)
print(c)

Solution (Python):
import math

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

x=abs(h*5+(5*(m/60))-m)*6
x=min(x,360-x)

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

Solution (Python):
import math

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

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

if S>L:
    rad=S-L
else:
    rad=L-S

if rad>=180:
    rad=360-rad

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

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

import math
PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB)))

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

degA = H * 30 + M * 0.5
degB = M * 6
deg = math.radians(degA-degB)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(deg)))

Solution (Python):
import math

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

degA = H * 30 + M * 0.5
degB = M * 6
deg = math.radians(degA-degB)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(deg)))

Solution (Python):
import math

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

M_ang=M/60*2*math.pi
H_ang= (H+M/60)*2*math.pi/12
angle= abs(H_ang-M_ang)
l= (A**2+B**2-2*A*B*math.cos(angle))**0.5

print(l)

Solution (Python):
import numpy as np
import math


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

d = np.sqrt((B*math.cos(math.radians(6*M))-A*math.cos(math.radians(30*H+M/2)))**2+(B*math.sin(math.radians(6*M))-A*math.sin(math.radians(30*H+M/2)))**2)
print(d)

Solution (Python):
import numpy as np
import math


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

d = np.sqrt((B*math.cos(math.radians(6*M))-A*math.cos(math.radians(30*H+M/2)))**2+(B*math.sin(math.radians(6*M))-A*math.sin(math.radians(30*H+M/2)))**2)
print(d)

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
m_rad = 6 * m
h_rad = 30 * h + m / 2
rad = abs(h_rad - m_rad)
rad = rad
if rad > 180:
    rad = 360 - rad
length_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(rad))
print(length_2**0.5)

Solution (Python):
import math

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

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

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

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

Solution (Python):
import math

def radi(n):
	return n * math.pi / 180

def resolve():
	a, b, h, m = map(int, input().split())
	hd = radi(h*30+30*(m/60))
	md = radi(360*(m/60))
	hx = a * math.cos(hd)
	hy = a * math.sin(hd)
	mx = b * math.cos(md)
	my = b * math.sin(md)
	x = abs(hx - mx)
	y = abs(hy - my)
	v = math.sqrt(x**2 + y**2)
	print(v)
resolve()

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

hrad = h * 30 + m * 0.5
mrad = m * 6

l = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(abs(hrad - mrad))))
print(l)

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


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

delta = abs((H/12 + (M/12/60)) - M/60)
theta = 2 * pi * delta

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

print(ans)

Solution (Python):
from math import cos, pi
a, b, h, m = map(int, input().split())
d = 5.5 * (h*60+m)
print((a*a + b*b - 2*a*b*cos(d/180*pi))**0.5)

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

import math

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



if math.degrees(M_rad)-0.1 < math.degrees(H_rad) < math.degrees(M_rad)+0.1:
  print(abs(A-B))
  exit()

elif 180-0.1 < math.degrees(rad) < 180+0.1:
  print(abs(A+B))
  exit()
else:
  
  C = math.sqrt(abs(A*A + B*B - 2*A*B*math.cos(rad)))
  print(abs(C))

Solution (Python):
import numpy as np

a = list(map(int,input().split()))
pi = np.pi
s = a[0]
l = a[1]
shi = a[2]
lon = a[3]
shi = shi * 30
shi = shi + 0.5*lon
lon = lon * 6
shi = shi*pi/180
lon = lon*pi/180
x_s = np.cos(shi)*s
y_s = np.sin(shi)*s
x_l = np.cos(lon)*l
y_l = np.sin(lon)*l
x = abs(x_s-x_l)
y = abs(y_s-y_l)
z = (x**2 + y**2)**(1/2)

print(z)

Solution (Python):
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.141592653/180*(30*H-11*M/2))))

Solution (Python):
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.141592653/180*(30*H-11*M/2))))

Solution (Python):
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.1415926535/180*(30*H-11*M/2))))

Solution (Python):
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(m.radians(30*H-11*M/2))))

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

Solution (Python):
import math
import numpy as np
while 1:
  A, B, H, M = map(int, input().split())
  if type(A) == int and type(B) == int and type(H) == int and type(M) == int:
    if 0 <= H and H <= 11:
      if 0 <= M and M <= 59:
        break
H_rotation = (360 / 12) * H + (360 / 12 / 60) * M
M_rotation = (360 / 60) * M
angle = abs(H_rotation - M_rotation)

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

Solution (Python):
import math

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



def get_point(radians_theta, r):
    
    
    
    x = r * math.sin(math.radians(radians_theta))
    y = r * math.cos(math.radians(radians_theta))
    return x, y

def calc_rad_big_hand(H, M):
    
    return H * 30 + M / 2

def calc_rad_little_hand(M):
    
    return M * 6

def calc_result(A,B,H,M):
    H = int(H)
    M = int(M)
    A = int(A)
    B = int(B)
    big_hand_rad = calc_rad_big_hand(H, M)
    little_hand_rad = calc_rad_little_hand(M)
    big_x, big_y = get_point(big_hand_rad, A)
    little_x, little_y = get_point(little_hand_rad, B)
    return math.sqrt((big_x - little_x)**2 + (big_y-little_y)**2)

print(calc_result(A,B,H,M))

Solution (Python):
import math

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


def get_point(radians_theta, r):
    
    
    
    x = r * math.sin(math.radians(radians_theta))
    y = r * math.cos(math.radians(radians_theta))
    return x, y

def calc_rad_big_hand(H, M):
    
    return H * 30 + M / 2

def calc_rad_little_hand(M):
    
    return M * 6

def calc_result(A,B,H,M):
    H = int(H)
    M = int(M)
    A = int(A)
    B = int(B)
    big_hand_rad = calc_rad_big_hand(H, M)
    little_hand_rad = calc_rad_little_hand(M)
    big_x, big_y = get_point(big_hand_rad, A)
    little_x, little_y = get_point(little_hand_rad, B)
    return math.sqrt((big_x - little_x)**2 + (big_y-little_y)**2)

print(calc_result(A,B,H,M))

Solution (Python):
import math
a,b,h,m = map(int, input().split()) 
minute = m + 60 * h
h2 = [a*math.sin(math.pi*minute/360),a*math.cos(math.pi*minute/360)]
m2 = [b*math.sin(math.pi*minute/30),b*math.cos(math.pi*minute/30)]
l = ((h2[0]-m2[0])**2 +(h2[1]-m2[1])**2 ) ** 0.5
print(l)

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

Solution (Python):
import math

a, b, h, m = map(int, input().split())
a_r = math.tau * (h + m / 60) / 12
b_r = math.tau * m / 60

x_d = a * math.sin(a_r) - b * math.sin(b_r)
y_d = a * math.cos(a_r) - b * math.cos(b_r)
print(math.sqrt(x_d * x_d + y_d * y_d))