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
a,b,h,m = map(int,input().split())
hun = h*60+m
ad = hun*0.5
bd = m*6

if abs(ad-bd) < 180:
    dg = abs(ad-bd)
    cos = math.cos(math.radians(dg))
    cc = a**2+b**2-2*a*b*cos
    print(math.sqrt(cc))
elif abs(ad-bd) == 180:
    print(a+b)
else:
    dg = 360-abs(ad-bd)
    cos = math.cos(math.radians(dg))
    cc = a**2+b**2-2*a*b*cos
    print(math.sqrt(cc))

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

if m == 0:
    argm = 0
else:
    argm = 360 * (m / 60)
if h == 0:
    if m == 0:
        argh = 0
    else:
        argh = 30 * (m/60)
else:
    if m == 0:
        argh = 360 * (h / 12)
    else:
        argh = 360 * (h / 12) + 30 * (m/60)
arg = abs(argh-argm)
print((a**2 + b**2 - 2*a*b*math.cos(math.radians(arg)))**0.5)

Solution (Python):

import math 
for _ in range(1):
    a,b,h,m = map(float,input().split())
    theta1 = ((2*math.pi)*(h*60.00++m))/(12.00*60.00)
    theta2 = ((2*math.pi)*(h*60.00++m))/(60.00)
    theta = theta2 - theta1 
    theta %= (2*math.pi)
    print('%.20f'%math.sqrt(a*a+b*b-2*a*b*math.cos(theta)))

Solution (Python):




import math

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


h = 360 * H / 12 + 360 / 12 * M /60
m = 360 * M / 60

if abs(h-m) < 180:
    k = abs(h-m)
else:
    k = 360 - abs(h-m)



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


print(ans)

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

Solution (Python):

import math

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

theta_h=float((math.pi * h) / 6 + (math.pi * m) / 360)
theta_m=float((math.pi * m) / 30)

x_2=float(a**2+b**2-2*a*b*math.cos(abs(theta_h-theta_m)))
x=math.sqrt(x_2)
print(x)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
at = 0
bt = 0
if m is not 0:
	at = 360 * m / 60
	if h is not 0:
		bt = 360*h/12 + 30*m/60
	else:
		bt = 30*m/60
elif h is not 0:
	bt = 360*h/12
t = math.radians(at-bt)
c = a*a + b*b - 2*a*b*math.cos(t)
print(math.sqrt(c))

Solution (Python):
import math
A,B,H,M = map(int,input().split())
theta = math.radians(min(abs((H*60+M)*0.5 - M*6),360-abs((H*60+M)*0.5 - M*6)))
print(math.sqrt((B-A*math.cos(theta))**2 + (A**2) * math.sin(theta)**2))

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


rShort = (h * (360 / 12)) + m * 1/2;


rLong = m * (360 / 60);


ang = abs(rLong - rShort);


ang = min(ang, (360 - ang));

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

Solution (Python):
import math
S = input()
A = int(S.split()[0])
B = int(S.split()[1])
H = int(S.split()[2])
M = int(S.split()[3])
m = 60*H + M
theta = m*math.pi/360
phi = m*math.pi/30
d = math.sqrt((A*math.sin(theta)-B*math.sin(phi))**2 + (A*math.cos(theta)-B*math.cos(phi))**2)
print(d)

Solution (Python):
import math


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



d = (60 * h + m) * 5.5 % 360
if d <= 180:
    s = d
else:
    s = 360 - d
ans = math.sqrt((a ** 2) + (b ** 2) - 2 * a * b * math.cos(math.radians(s)))
print(ans)

Solution (Python):
import numpy as np
A,B,H,M=map(int,input().split())
c=360*np.pi/180
k=abs(c/(12*60*60)*(H*60*60+M*60)-c/60*M)
print(np.sqrt(A**2+B**2-2*A*B*np.cos(k)))

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

h_fra = H / 720
m_fra = m / 60

theta = (h_fra - m_fra) * 2 * math.pi
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(theta))
print(c)

Solution (Python):
import math
import numpy as np

def main():
    A,B,H,M = map(int, input().split())
    min = H*60+M
    
    H_loc = min * 0.5
    M_loc = M * 6
    
    if abs(H_loc-M_loc) > 180:
        theta = 360 - abs(H_loc - M_loc)
    else:
        theta = abs(H_loc - M_loc)
    
    
    r = math.sqrt(A**2 + B**2 - 2*A*B*np.cos(np.radians(theta)))
    print(r)
    
    
    
    
if __name__ == '__main__':
    main()

Solution (Python):
import math

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

hun = 60* H + M 
kaku= min (360-(5.5)*hun , 5.5*hun)

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

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

l = m * 6
s = h * 30 + m * 0.5
theta = abs(l - s)

c = a*a + b*b - 2*a*b*math.cos(math.radians(theta))
print('{:.15f}'.format(math.sqrt(c)))

Solution (Python):


import math

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

sub = abs(360 * ((H * 60 + M) / (12 * 60)) - 360 * (M / 60))
deg = min(sub, 360 - sub)
rad = math.radians(deg)

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

print(ans ** (1 / 2))

Solution (Python):
import math

MINUTES_L = 6       
MINUTES_S = 0.5     
HOURS_S = 30        

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

angle_L = MINUTES_L * m
angle_S = HOURS_S * H + MINUTES_S * m


radian = angle_L * math.pi / 180
y_L = math.sin(radian) * B
x_L = math.cos(radian) * B


radian = angle_S * math.pi / 180
y_S = math.sin(radian) * A
x_S = math.cos(radian) * A


ans = math.sqrt((x_L - x_S) * (x_L - x_S) + (y_L - y_S) * (y_L - y_S))

print(ans)

Solution (Python):
import math
A,B,H,M=(int(x) for x in input().split())
ang=30*H+0.5*M-6*M
L=math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(ang)))
print(L)

Solution (Python):
import sys
import math
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
import itertools
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, H, M = MAP()

if abs(30 * H - 5.5 * M) % 360 <= 180:
    theta = abs(30 * H - 5.5 * M) % 360
else:
    theta = 360 - abs(30 * H - 5.5 * M) % 360

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

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

bb=float(6*m)
aa=float(0.5*(h*60+m))
c=aa-bb
d=bb-aa
if c<0:
    s=d
else:
    s=c
cc=360.0-s
if cc<s:
    s=cc
import math

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

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

Solution (Python):
import numpy as np

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

angle_M = M/60*2.*np.pi
angle_H = H/12*2.*np.pi+M/60*np.pi/6.

D = np.sqrt(A**2 + B**2 - 2.*A*B*np.cos(angle_M-angle_H))
print(D)

Solution (Python):
import math

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

h_ = (h/12 + m/720) * 360
m_ = m*6

x = math.radians(max(h_, m_) - min(h_, m_))
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(x))

print(ans)

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

Solution (Python):
import math
A,B,H,M = map(int,input().split())
tmp_a = ((H%12)*30+0.5*M)%360
tmp_b = 6*M
tmp = abs(tmp_a-tmp_b)
r_2 = A**2 + B**2 -2*A*B*math.cos(math.radians(tmp))
print(math.sqrt(r_2))

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

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

 

deg = math.radians(abs(degA - degB))


output = math.sqrt(A*A + B*B - 2*A*B*math.cos(deg))
print(output)

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

Solution (Python):
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import radians,cos

def main():
    a,b,H,M = map(int,input().split())
    H *= 30
    H += M/2
    M *= 6
    x = min(360-abs(H - M),abs(H-M))
    x = radians(x)
    ans = a*a + b*b - 2*a*b*cos(x)
    print(ans**0.5)
if __name__ == '__main__':
    main()

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

hDegree = H * 30 + M / 2
mDegree = M * 6
bDegree = abs(hDegree - mDegree)

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

Solution (Python):
import numpy as np

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

h_r = (h/12)*360+(30*(m/60))
m_r = (m/60)*360

r = abs(h_r - m_r)

if r > 180:
    r = 360 - r


cos = np.cos(np.deg2rad(r))


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

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

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

print(math.sqrt(a*a+b*b-2*a*b*math.cos(2*math.pi*(H/12.0-(11/12.0)*M/60.0))))

Solution (Python):
import math
import numpy as np

a, b, h, m = map(int, input().split())
hma = math.pi*2/(12*60)*m
ha = (math.pi*2/12)*(h%12)+hma
ma = (math.pi*2/60)*m

getvec = lambda r, angle: np.array([r*math.cos(angle), r*math.sin(angle)])
hvec = getvec(a, ha)
mvec = getvec(b, ma)
vv = hvec - mvec
print(math.sqrt(vv[0]**2+vv[1]**2))

Solution (Python):
import math
A, B, H, M = map(float, input().split())
theta1 = (360 * H / 12) + (30 * M / 60)
theta2 = 360 * M / 60
theta = abs(theta1 - theta2)
C = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(theta)))
print(C)

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

a_hour_cm, b_min_cm, h_time_hour, m_time_min = map(int, input().split())

min_hand_angle = m_time_min * 6
hour_hand_angle = h_time_hour * 30 + m_time_min / 2

sandwiched_angle = abs(hour_hand_angle - min_hand_angle)

result = sqrt(a_hour_cm ** 2 + b_min_cm ** 2 - 2 * a_hour_cm * b_min_cm * cos(radians(sandwiched_angle)))
print(result)

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


x1 = a * math.cos(math.radians(360 * (h * 60 + m) / 720))
y1 =  a * math.sin(math.radians(360 * (h * 60 + m) / 720))

x2 =  b * math.cos(math.radians(360 * m / 60))
y2 =  b * math.sin(math.radians(360 * m / 60))

print(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2))

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

def angle(hour,mini):
	 h = (hour * 360) / 12 + (mini * 360) / (12 * 60)
	 m = (mini * 360) / (60)
	 angle = abs(h - m)
	 if (angle > 180):
	     angle=360-angle
	 return (angle*math.pi)/180
an=angle(h,m)
print(math.sqrt((a*a)+(b*b)-(2*a*b*(math.cos(an)))))

Solution (Python):
from math import radians,sqrt,cos
a,b,h,m = map(int,input().split())
short = h*5 + 5*(m/60)
long = m

gap = min(abs(60-abs(long-short)),abs(long-short))
arg = 6*gap

x = radians(arg)
print(sqrt(a**2+b**2-2*a*b*cos(x)))

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

print(ans_2**(1/2))

Solution (Python):
import math
a,b,h,m=[int(_) for _ in input().split()]

s=[a*math.cos(math.radians(-(30*h+(m/2))+90)),a*math.sin(math.radians(-(30*h+m/2)+90))]
l=[b*math.cos(math.radians(-(6*m)+90)),b*math.sin(math.radians(-(6*m)+90))]
print(math.sqrt((s[0]-l[0])**2+(s[1]-l[1])**2))

Solution (Python):
import math
a,b,h,m=map(int,input().split())
theta_1=(h+(m/60))*(math.pi/6)
theta_2=m*(math.pi/30)
theta_1=2*math.pi-(theta_1-math.pi/2)
theta_2=2*math.pi-(theta_2-math.pi/2)

y1=a*math.sin(theta_1)
x1=a*math.cos(theta_1)

y2=b*math.sin(theta_2)
x2=b*math.cos(theta_2)

print(math.sqrt((x1-x2)**2+(y1-y2)**2))

Solution (Python):
import math
A,B,H,M=list(map(int,(input().split())))
anc=abs(H*30+(30*M/60)-M*6)

anc=math.cos(math.radians(anc))

temp_ans=A**2+B**2-2*A*B*anc
print(math.sqrt(temp_ans))

Solution (Python):
import math

A, B, H, M = map(int, input().split())
if M == 0:
  jishin = 360 / 12 * H
else:
  jishin = 360 / 12 * H + 360 / 12 / 60 * M
funshin = 360 / 60 * M
angle = abs(jishin - funshin)
if angle >= 180:
  angle = 360 - angle

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

print(length)

Solution (Python):
import math

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

rad_a = (h/12+ (1/12) * (m/60))*360
rad_b = (m/60)*360

if rad_a == rad_b:
    print(abs(b-a))
elif abs(rad_a - rad_b) == 180:
    print(b+a)
else:
    print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(abs(rad_a-rad_b)))))

Solution (Python):
import math

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

k_a = (30 * (h + m/60))/360 * math.pi *2
k_b = (6 * m)/360 * math.pi *2

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

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

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

rad = abs(rad_h - rad_m)

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

print(r)

Solution (Python):
import math


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

_h = (H * 60 + M) * 0.5
_m = M * 6

theta = abs(_h - _m)
theta = 360 - theta if theta > 180 else theta
theta = math.radians(theta)

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

print(c)

Solution (Python):

a,b,h,m=map(int, input().split())
b_k = 360*(1/60)*m
a_k = 360*(1/12)*h+(360/12)*(1/60)*m

import math
if abs(b_k-a_k) > 180:
    k_dif = 360-abs(b_k-a_k)
else:
    k_dif = abs(b_k-a_k)
c_2 = a**2+b**2-(2*a*b*math.cos(math.radians(k_dif)))  
answer = math.sqrt(c_2)
print(answer)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
a = H*30 + M*0.5
b = M*6
r = abs(a-b)
if r > 180:
    r = 360-r
if r == 180:
    print(A+B)
    exit()

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

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

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

theta = min(theta, 360 - theta)

import math

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

print(x_2**0.5)

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

zi=30*h
hun=6*m


theta=np.abs(zi-hun)

if theta>180:
    theta=360.0-theta
theta*=np.pi/180.0

ans=a**2.0+b**2.0-2.0*np.cos(theta)*a*b
ans=ans**0.5


print(ans)

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

C = 2 * math.pi * (60*h - 11*m) / 720
c = a**2 + b**2 - 2*a*b*math.cos(C)
print(math.sqrt(c))

Solution (Python):
import math

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

x0 = A * math.sin(math.pi * (H / 6 + M / 360))
y0 = A * math.cos(math.pi * (H / 6 + M / 360))

x1 = B * math.sin(math.pi * M / 30)
y1 = B * math.cos(math.pi * M / 30)

print(math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2))

Solution (Python):
import math

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

a_angle = h * 30 + m / 2
b_angle = m * 6
cos_x = math.cos(math.radians(a_angle-b_angle))
d = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos_x)
print(d)

Solution (Python):
import numpy as np
import sys
import math

pi = 3.1415926535897923

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

sh1 = 360 * ( (H*60 + M) % 720 ) / 720
sh2 = 360 * ( M % 60 ) / 60
sh = min(abs(sh1-sh2) , 360 - abs(sh1-sh2))

print(math.sqrt( A ** 2 + B ** 2 - 2 * A * B * math.cos( ( sh * pi) / 180 )  ) )

Solution (Python):
import math
t = input().split()
t = [int(i) for i in t]
r = math.sqrt(t[0]*t[0]+ t[1]*t[1])
h = t[2]
m = t[3]
if (h == 12):
    h = 0
if (m == 60):
    m = 0
hour_angle = 0.5 * (h * 60 + m) 
minute_angle = 6 * m 
angle = abs(hour_angle - minute_angle) 
angle = min(360 - angle, angle)
print(math.sqrt(r*r - 2*t[0]*t[1]*math.cos(angle*(2*math.pi/360))))

Solution (Python):
import sys
import math
A,B,H,M=map(int, sys.stdin.readline().split())
fun=360*float(M)/60
ji=30*H+30*float(M)/60
print (A**2+B**2-2*A*B*math.cos(math.radians(abs(fun-ji))))**0.5

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,sin,cos,radians,tan
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





a,b,h,m=mii()
h%=12

hun = [b*sin(radians(360*m/60)),b*cos(radians(360*m/60))]

zi=[a*sin(radians(360*h/12 + 360*m/60/12)),a*cos(radians(360*h/12+ 360*m/60/12))]

ans = ((hun[0]-zi[0])**2 + (hun[1]-zi[1])**2)**0.5

print(ans)

Solution (Python):
import math
a,b,h,m = map(int,input().split())
theta_a = 30*h + 0.5*m
theta_b = 6*m
if abs(theta_a - theta_b) < 180:
    theta_diff = abs(theta_a-theta_b)
elif abs(theta_a - theta_b) > 180:
    theta_diff = 360-abs(theta_a-theta_b)
if abs(theta_a - theta_b)==180:
    ans = a+b
else:
    ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(theta_diff)))
print(abs(ans))

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

deg = abs(h*30 + (m/60.)*30. - (6*m))
print("%.20f" % sqrt(a**2 + b**2 - 2*a*b*cos(deg*pi/180.)))

Solution (Python):
import math

a,b,h,m=map(int,input().split())
h%=12
ah=h*30+m*0.5
am=m*6
angle=abs(ah-am)
if angle>180:
    angle-=(angle-180)*2
if angle>90:
    bh=b*math.sin(math.radians(angle-90))
    bw=b*math.cos(math.radians(angle-90))
    print(((a+bh)**2+bw**2)**0.5)
else:
    bh=b*math.sin(math.radians(90-angle))
    bw=b*math.cos(math.radians(90-angle))
    print(((a-bh)**2+bw**2)**0.5)

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

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

theta = min(theta, 360 - theta)

import math

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

print(x_2**0.5)

Solution (Python):
from math import cos, sin, sqrt, radians
a, b, h, m = map(int,input().split())
hm = 60 * h + m
angled = abs(hm / 2 - 6 * m)
angle = radians(angled)
x = pow(a-b*cos(angle), 2)
y = pow(b*sin(angle),2)
print(sqrt(x+y))

Solution (Python):


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



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

print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(abs(h_theta-m_theta)))))

Solution (Python):
import math as m


def resolve():
    A, B, H, M = [int(i) for i in input().split()]
    x = abs(360 / 60 * M - (0.5 * (60 * H + M)))
    ans = m.sqrt((A)**2 + (B)**2 - (2 * A * B) * m.cos(m.radians(x)))
    print(ans)


resolve()

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

import math





H = H + M/60



tH = math.radians(360*(H%12)/12)
tM = math.radians(360*(M%60)/60)










pH = (A*math.sin(tH), A*math.cos(tH))
pM = (B*math.sin(tM), B*math.cos(tM))

D = (pH[0] - pM[0])**2 + (pH[1] - pM[1])**2


print(D**0.5)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
h=360*(h/12)+360*(1/12)*(m/60)
m=360*(m/60)
angle=abs(h-m)
if angle>=180:
  angle=360-angle
ans=math.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())


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


print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
l=a**2+b**2
k=2*a*b
p=math.pi
print((l-k*math.cos(abs((p*h/6)-(11*m*p/360))))**0.5)

Solution (Python):
import math
A,B,H,M =  list(map(int, input().split()))
time = 60*H+M
long_d = 0.5*time
short_d = 6*time%360
d = abs(long_d - short_d)
Cos = math.cos(math.radians(d))
ans = A*A + B*B - 2*A*B*Cos
ans = math.sqrt(ans)
print(ans)

Solution (Python):
import math

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

ang_a = 30 * h + m / 2
ang_b = 6 * m
ang_c = max(ang_a, ang_b) - min(ang_a, ang_b)
if ang_c > 180: ang_c = 360 - ang_c
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(ang_c)))
print(ans)

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

h_kaku = math.radians(h*30+m*(1/2))
m_kaku = math.radians(m*6)

a_x = math.sin(h_kaku)*a
a_y = math.cos(h_kaku)*a
b_x = math.sin(m_kaku)*b
b_y = math.cos(m_kaku)*b

ans = math.sqrt((a_x-b_x)**2+(a_y-b_y)**2)

print(ans)

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

hh=360*(60*h+m)/(60*12)
mm=360*(m/60)
rad=hh-mm
if rad > 180:
    rad=360-rad
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad))))

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

Solution (Python):
import math
A,B,N,M=map(int,input().split())
h_angle=0
m_angle=0
m_angle=M*6
angle_1=0
angle_2=0
angle=0
if N>=12:
    h_angle=(N-12)*30+M/2
else:
    h_angle=N*30+M/2
angle_1=abs(h_angle-m_angle)
angle_2=360-angle_1
if angle_1>=angle_2:
    angle=angle_2
else:
    angle=angle_1
angle=math.radians(angle)
print(math.sqrt((min(A,B)*math.sin(angle))**2+(max(A,B)-min(A,B)*math.cos(angle))**2))

Solution (Python):
import math

l=list(map(int, input().split(' ')))
a=l[0]
b=l[1]
h=l[2]
m=l[3]
hours = (h+m/60)/12
minutes = m/60
theta = 2*math.pi*(hours-minutes)
ans = a**2+b**2-2*a*b*math.cos(theta)
print(ans**0.5)

Solution (Python):
import math

if __name__ == "__main__":
    a, b, h, m = map(int, input().split())

    p = math.pi
    alpha = (60 * h + m) * p / 360
    beta = p * m / 30
    theta = alpha - beta

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

    print(c)

Solution (Python):
import sys






import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def ri():
    return list(map(int, input().split()))
def rs():
    return list(input().strip())
a, b , h , m = ri()

ang=abs((h+m/60)*30-m*6)

c = np.sqrt(a**2+b**2-2*a*b*np.cos(ang/180*np.pi))

print(c)

Solution (Python):


import math
a,b,h,m = list(map(int, input().split()))
oa = (60*h + m)/2
ob = m*6
cos_ab = math.cos(math.radians(oa-ob))
c = abs((a**2 + b**2 -2*a*b*cos_ab)**0.5)
print(c)

Solution (Python):
import math
a, b, h, m = map(int, input().split());
min = 60 * h + m;

d = math.radians((min * 5.5) % 360);
cos = math.cos(d);

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

Solution (Python):
A,B,H,M = map(int,input().split())
import math
H_arg = 30*H + 0.5*M
M_arg = 6*M
arg = min(abs(H_arg - M_arg),abs(M_arg -H_arg),abs(360-(abs(H_arg - M_arg))),abs(360-(abs(M_arg - H_arg))))

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

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



def main():
    A, B, H, M = [int(i) for i in input().strip().split()]
    rad_h = math.radians(H * (360/12) + (360/12) * M/60)
    rad_m = math.radians(360 * M / 60)
    rad = abs(rad_h - rad_m)
    if rad > math.pi:
        rad = 2 * math.pi - rad

    return (A**2 + B**2 - 2 * A * B * math.cos(rad)) ** (1/2)


if __name__ == "__main__":
    print(main())

Solution (Python):
import math

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

htheta = h*30 + m*0.5 
mtheta = m*6









l2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(htheta-mtheta))
print(l2**0.5)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
def ret(hour, minute):
    ans = abs((hour * 30 + minute * 0.5) - (minute * 6))
    x = min(360-ans,ans)
    return (x * math.pi) / 180.0

c = ret(h, m)
print(math.sqrt(a ** 2 + b ** 2 - (2 * a * b * (math.cos(c)))))

Solution (Python):
import math

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

hkaku = (h*30+0.5*m)%360
mkaku = (m*6)%360

theta = math.radians(hkaku-mkaku)

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

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

Solution (Python):
import math

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

c = math.radians(30*h+m/2)
d = math.radians(6*m)

if c>=d:
  ans = math.sqrt(a**2+b**2-2*a*b*math.cos(c-d))
  print(ans)
elif c<d:
  ans = math.sqrt(a**2+b**2-2*a*b*math.cos(d-c))
  print(ans)

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




fun = 360/60 * M
th_fun = fun - 90




jis = 360/12 * H + 360/12/60 * M
th_jis = jis - 90


cos_f = B * cos(radians(th_fun))
sin_f = B * sin(radians(th_fun))

cos_j = A * cos(radians(th_jis))
sin_j = A * sin(radians(th_jis))


dist =((cos_f - cos_j)**2 + (sin_f - sin_j)**2)**0.5

print(dist)

Solution (Python):
import sys
import itertools
import numpy as np
from collections import Counter
import math

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

hdeg = H/12*2*math.pi+M/60*math.pi/6
mdeg = M/60*2*math.pi
diff = abs(hdeg-mdeg)

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

Solution (Python):
A,B,H,M = map(int,input().split())
import math
X = M*math.pi/30
Y = H*math.pi/6 + M*math.pi/360

Z = abs(X - Y)
if Z>=math.pi:
  Z = 2*math.pi - Z

if Z==math.pi:
  print(A + B)
else:
  print((A**2 + B**2 - (2*A*B*math.cos(Z)))**(1/2))

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

Solution (Python):
import math
A,B,H,M = map(int, input().split())
hth = 30*H + 0.50*M
mth = 6*M
c2 = A**2 + B**2 -2*A*B*math.cos(math.radians(hth-mth))
print(math.sqrt(c2))

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

deg = max((h/12)*360, (m/60)*360) - min((h/12)*360, (m/60)*360)

if deg > 180:
    deg = 360 - deg

print((a**2 + b**2 - 2*a*b*math.cos(math.radians(deg)))**(0.5))

Solution (Python):
import math

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


h = h % 12

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

ax = a * math.sin(h)
ay = a * math.cos(h)
bx = b * math.sin(m)
by = b * math.cos(m)

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

Solution (Python):
import math

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

theta_h = (60 * h + m)/2
theta_m = 6 * m
the = abs(theta_h -theta_m)
the = min(the, 360 - the)

r = (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(the))) ** (1/2)
print(r)

Solution (Python):
import math
A,B,H,M=map(int,input().split())
time=60*H+M
Adeg=(time/720)*360
Bdeg=(M/60)*360
kakudo=abs(Adeg-Bdeg)
if kakudo==0  :
  print(abs(A-B))
elif kakudo== 180:
  print(A+B)
elif kakudo>180:
  kakudo=360-kakudo
  ans=math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(kakudo)))
  print(ans)
else:
  ans=math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(kakudo)))
  print(ans)

Solution (Python):
import math

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

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

angle_2 = math.radians(angle)

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

Solution (Python):
import math

hour_hand, min_hand, hour, minutes = map(int, input().split())

hour_hand_degree = 30 * hour + 30 * minutes / 60
min_hand_degree = 360 * minutes/60


hour_coordinate = [math.sin(math.radians(hour_hand_degree)) *
                   hour_hand, math.cos(math.radians(hour_hand_degree)) * hour_hand]
min_coordinate = [math.sin(math.radians(min_hand_degree))*min_hand,
                  math.cos(math.radians(min_hand_degree)) * min_hand]


print(math.sqrt((hour_coordinate[0] - min_coordinate[0]) **
                2 + (hour_coordinate[1] - min_coordinate[1])**2))

Solution (Python):
import math

inp = input().split(" ")



A = int(inp[0])

B = int(inp[1])

H = int(inp[2])

M = int(inp[3])

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

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

print(str(C))

Solution (Python):
import math

short, long, hour, minute = map(int, input().split())
time = hour * 60 + minute
s_angle = math.pi * (time / 720) * 2
l_angle = math.pi * (minute / 60) * 2
l_x = long * math.cos(l_angle)
l_y = long * math.sin(l_angle)
s_x = short * math.cos(s_angle)
s_y = short * math.sin(s_angle)
r_long = math.sqrt((l_x - s_x) ** 2 + (l_y - s_y) ** 2)
print(r_long)

Solution (Python):
import math
A, B, H, M = map(int,input().split())
pi = math.pi
theta_A = 2*pi*H/12 + 2*pi*M/(60*12)
theta_B = 2*pi*M/60
point_A = [A*math.cos(theta_A), A*math.sin(theta_A)]
point_B = [B*math.cos(theta_B), B*math.sin(theta_B)]
r = ((point_A[0]-point_B[0])**2 + (point_A[1] - point_B[1])**2 )**0.5
print(r)

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



l_rad = 360*(m/60)

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


x = abs(s_rad-l_rad)
if x > 180:
    x = 360 - x

import math
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())
rad = 30 * H + 0.5 * M
rada = 6 * M
radi = rad - rada
c=math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(radi)))
print(c)

Solution (Python):
import math

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

Solution (Python):

import sys
import collections
import math

sys.setrecursionlimit(10 ** 7)


A, B, C, D = list(map(int, input().rstrip().split()))
ar = (360 / 12) * C + D * 0.5
br = (360 / 60) * D

print(math.sqrt(A * A + B * B - (2 * A * B * math.cos(math.radians(abs(ar - br))))))

Solution (Python):
import math

def get_cos(m, h):
  a_deg = h*30 + m/2
  b_deg = m*6
  deg = min(abs(a_deg - b_deg), abs(360 - a_deg + b_deg))
  cos = math.cos(math.radians(deg))
  
  return cos

if __name__ == '__main__':
  a, b, h ,m = map(int,input().split())
  print(math.sqrt(a*a + b*b - 2*a*b*get_cos(m, h)))

Solution (Python):
import math
A,B,H,M =  (int(x) for x in input().split())
h = 360*H/12 + 30*M/60
m = 360*M/60
c = abs(h-m)
if(c > 180):
    c = 360 - c
C = A**2 + B**2 - 2*A*B*math.cos(math.radians(c))
if c != 180 and c != 0:
    print(math.sqrt(C))
elif c == 180:
    print(A+B)
else:
    print(abs(A-B))