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())

def get_theta(h,m):
		cand = abs(m*6 - (h*30 + m*0.5))
		theta = math.radians([cand, 360 - cand][cand > 180])
		return theta

def cos_thm(a,b,theta):
		c_squared = (a**2) + (b**2) - (2*a*b*math.cos(theta))
		return math.sqrt(c_squared)

theta = get_theta(H,M)
if theta == 0:
		ans = abs(A-B)
elif theta == 180:
		ans = A+B
else:
		ans = cos_thm(A,B,theta)

print(ans)

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

s = (60*h+m)/360*math.pi
l = m/30*math.pi
sx = a*math.sin(s)
sy = a*math.cos(s)
lx = b*math.sin(l)
ly = b*math.cos(l)
print(math.sqrt(((sx-lx)**2+(sy-ly)**2)))

Solution (Python):
from math import acos,cos,sin
pi = acos(-1)

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

a = (H*60+M)/720*(2*pi)
b = M/60*(2*pi)

posA = A*cos(a),A*sin(a)
posB = B*cos(b),B*sin(b)

print(sum([(posA[i]-posB[i])**2 for i in range(2)])**.5)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
tyousindeg = M*360/60
tannsinndeg = H*360/12+30*M/60
lst = sorted([tyousindeg,tannsinndeg])
C = lst[1]-lst[0]
if C > 180:
  C = 360 - C
kyori = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(C)))
print(kyori)

Solution (Python):
import math
A, B, H, M = map(int, input().split(' '))
deg = abs(M * 6 - (H * 30 + 0.5 * 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())
c = abs((60*h+m)*0.5 - m*6)
if c>180:
    c=360-c
c=(a**2 + b**2 - 2*a*b*math.cos(math.radians(c)))**0.5
print(c)

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

x_hour = a * math.cos((hour + minute/ 60)*30/180 * math.pi)
x_min = b * math.cos(minute*6 / 180 * math.pi)
y_hour = a * math.sin((hour + minute/ 60)*30/180 * math.pi)
y_min = b * math.sin(minute*6 / 180 * math.pi)

print(math.sqrt((x_hour - x_min) ** 2 + (y_hour - y_min) ** 2))

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

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

t1 = math.radians(M * 360 / 60)
x1 = B * math.sin(t1)
y1 = B * math.cos(t1)

t2 = math.radians((H * 60 + M) * 360 / (12 * 60))
x2 = A * math.sin(t2)
y2 = A * math.cos(t2)

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

Solution (Python):
import math

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

hc=360/12*h+30/60*m 
mc=360/60*m 
hm=abs(hc-mc) 
if hm > 180:
    hm=360-hm

mcos=math.cos(math.radians(hm))
c=a**2+b**2-(2*a*b*mcos) 

print(math.sqrt(c))

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

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

Solution (Python):
import math

A, B, H, M = map(int, input().split(' '))
deg = abs((6 * M - (30 * H + 0.5 * 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())
theta = abs( (h/12) + (m/60) * (1/12) - m/60)*2*math.pi


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

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

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

h_s = 360*h/12+30*m/60
m_s = 360*m/60
s = abs(h_s - m_s)
print(abs(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(s)))))

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

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

ji = np.array([A*math.cos(-math.pi/6*(H+M/60) + math.pi/2), A*math.sin(-math.pi/6*(H+M/60) + math.pi/2)])

hun = np.array([B*math.cos(-math.pi/30*M + math.pi/2), B*math.sin(-math.pi/30*M + math.pi/2)])

print(math.sqrt(((ji-hun)**2).sum()))

Solution (Python):
import math

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


A_deg=H*(360/12) + M*(360/12/60)
B_deg=M*(360/60)
deg=abs(A_deg-B_deg)

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

print(ans)

Solution (Python):
import math

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

angle_M = M*(360/60)
angle_H = H*(360/12)+angle_M/12

delta = min(abs(angle_H-angle_M),360-abs(angle_H-angle_M))

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

print(dist)

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

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

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

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

M_angle=M*6
h_=0
if M_angle>0: 
    h_=30/(360/M_angle)
H_angle=H*5*6+h_
Angle=abs(H_angle-M_angle)
Cos=np.cos(np.deg2rad(Angle))

ans_=(A**2)+(B**2)-(2*A*B*Cos)
ans=ans_**0.5
print(ans)

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

M_angle=M*6
h_=0
if M_angle>0: 
    h_=30/(360/M_angle)
H_angle=H*5*6+h_
x=abs(H_angle-M_angle)
y=abs(360-x)
Angle=min(x,y)
Cos=np.cos(np.deg2rad(Angle))

ans_=(A**2)+(B**2)-(2*A*B*Cos)
ans=ans_**0.5
print(ans)

Solution (Python):
from decimal import *
from math import *
a, b, h, m = map(float, input().split())
ana = 360*(60*h+m)/720
anb = 360*m/60
an = min(abs(ana-anb), abs(anb-ana))
sint = sin(radians(an))
cost = cos(radians(an))
l = Decimal(((b-a*cost)**2 + (a*sint)**2)**.5)
print(l)

Solution (Python):
import io
import sys
import math

def solve():
    A, B, H, M = list(map(int, input().split()))
    C_sq = A**2 + B**2 - 2*A*B*math.cos((H - 11/60 * M)*math.pi/6)
    C = math.sqrt(C_sq)
    print(C) 


if __name__ == "__main__":
    solve()

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


A, B, H, M = map(int, input().split())
ang_A = (H * 60 + M) / 360 * pi
ang_B = (H * 60 + M) / 30 * pi
ang_C = abs(ang_A - ang_B)
if ang_C > pi:
    ang_C = 2 * pi - ang_C
C = sqrt(A**2 + B**2 - 2*A*B*cos(ang_C))
print(C)

Solution (Python):
import math


def law_of_cosine(x, y, angle_between_x_y):
    rad = math.radians(angle_between_x_y)
    z = (x ** 2 + y ** 2 - 2 * x * y * math.cos(rad)) ** (1 / 2)
    return z


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

    h_angle = 30 * h + 0.5 * m
    m_angle = 6 * m
    between_angle = abs(h_angle - m_angle)
    angle = min(between_angle, 360 - between_angle)

    cm = law_of_cosine(a, b, angle)
    print(cm)


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import math
a = [int(s) for s in input().split()]
b = int(max([a[0], a[1]]))
c = int(min([a[0], a[1]]))
d = 0.5 * (a[2] * 60 + a[3])
e = 6 * a[3]
f = abs(d - int(e))

if f >= 180:
  f = 360 - f
if f != 0 and f!= 180:
  print(math.sqrt(a[0] ** 2 + a[1] ** 2 - 2 * a[0] * a[1] * math.cos(math.radians(f))))
elif f == 0:
  print(b-c)
else:
  print(b+c)

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

Solution (Python):
import math

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

Minute_angle = (M / 60) * 2 * math.pi
Time_angle = (H + (M / 60)) * math.pi / 6
theta = Minute_angle - Time_angle
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
print(ans)

Solution (Python):
import math

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


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

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

print(ans)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
ax = a * math.cos(math.radians((h/12 + 1/12 * m/60) * 360))
ay = a * math.sin(math.radians((h/12 + 1/12 * m/60) * 360))
bx = b * math.cos(math.radians(m/60 * 360))
by = b * math.sin(math.radians(m/60 * 360))
print(math.sqrt((ax-bx)**2 + (ay-by)**2))

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


def getdegree(n,m):
    degm=m*6
    degn=(n%12)*30 + 0.5*m
    return min(abs(degn-degm), 360-abs(degn-degm))

D=math.radians(getdegree(H,M))

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

Solution (Python):


import math

def main():
    a, b, h, m = map(int, input().split())
    arg_a = 360 * (h * 60 + m) / (12 * 60)
    arg_b = 360 * m / 60
    arg = min(abs(arg_a - arg_b), 360 - abs(arg_a - arg_b))
    
    c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(arg)))
    
    print(c)
    
main()

Solution (Python):
import math

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

time = h * 60 + m

ta = time * 2 * math.pi / (12 * 60)
tb = time * 2 * math.pi / 60

xa = a * math.sin(ta)
ya = a * math.cos(ta)
xb = b * math.sin(tb)
yb = b * math.cos(tb)

ans = math.sqrt((xa-xb)**2 + (ya-yb)**2)
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(math.radians(abs(30*H + 0.5*M - 6*M)))))

Solution (Python):
import math

A, B, H, M = list(map(lambda n: int(n), input().split(" ")))

thetaM = 6 * M
thetaH = 30 * H + 0.5 * M
theta = math.radians(180 - abs(abs(thetaH - thetaM) - 180))

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

Solution (Python):
import math


def main(a, b, h, m):
    
    rad1 = 2 * math.pi * (h + m / 60.0) / 12.0
    x1 = a * math.cos(rad1)
    y1 = a * math.sin(rad1)

    
    rad2 = 2 * math.pi * m / 60.0
    x2 = b * math.cos(rad2)
    y2 = b * math.sin(rad2)

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


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

Solution (Python):
import math

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

theta = abs((m/30) - (h/6 + m/360))*Pi
C = (a*math.sin(theta))**2 + (b-a*math.cos(theta))**2
c = math.sqrt(C)

print(c)

Solution (Python):
import math

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

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

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

Solution (Python):
import math

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

theta = abs((m/30) - (h/6 + m/360))*Pi
C =  a**2 + b**2 - 2*a*b*math.cos(theta)
c = math.sqrt(C)

print(c)

Solution (Python):


import numpy as np
import math

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

time=(60*H+M)
a=360/720*time
b=360/60*M
c=math.radians(b-a)


print((A**2+B**2-2*A*B*np.cos(c))**0.5)

Solution (Python):
import math

a,b,H,M=map(int,input().split())

theta_a = math.pi/6 * (H+M/60)
theta_b = math.pi*2*M/60

theta = abs(theta_a - theta_b)

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

print(ans)

Solution (Python):
import math

a,b,H,M=map(int,input().split())

theta_a = math.pi/6 * (H+M/60)
theta_b = math.pi*2*M/60

ans = math.sqrt((b*math.cos(theta_b) - a*math.cos(theta_a))**2 + (b*math.sin(theta_b) - a*math.sin(theta_a))**2)

print(ans)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
arg_H = (360*H)/12+(30*M)/60
if M ==0:
    arg_M = 360
else:
    arg_M = (360*M)/60
HM = abs(arg_H-arg_M)
arg_HM = min(HM, 360-HM)
CM2 = A**2+B**2-2*A*B*math.cos(math.radians(arg_HM))
CM = math.sqrt(CM2)
print(CM)

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

arg_hour = 2* math.pi *rel_hour
arg_min = 2*math.pi * m/60
ans = (abs(a**2+b**2-2*a*b*math.cos(arg_hour-arg_min)))**(1/2)
print(ans)

Solution (Python):
import math

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

c = math.cos(math.radians(360 - abs(30 * H + 0.5 * M - 6 * M)))
X_2 = A ** 2 + B ** 2 - 2 * A * B * c
X = math.sqrt(X_2)

print(X)

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

rad = abs((30*H+30*M/60)-6*M)
if rad >= 180:
    rad = 360-rad

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

print(math.sqrt(c))

Solution (Python):
import math
if __name__ == '__main__':
    a, b, h, m = map(int, input().split())
    h_y = a * math.sin(math.pi* (0.5+(-2)*(h*3600+m*60)/43200))
    h_x = a * math.cos(math.pi* (0.5+(-2)*(h*3600+m*60)/43200))
    m_y = b * math.sin(math.pi* (0.5+(-2)*m/60))
    m_x = b * math.cos(math.pi* (0.5+(-2)*m/60))
    print(math.sqrt((h_y-m_y)**2 + (h_x-m_x)**2))

Solution (Python):
import math

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

A_degree = (360 / (60 * 12)) * (H * 60 + M)
B_degree = (360 / 60) * M

A_x = A * math.cos(math.radians(A_degree))
A_y = A * math.sin(math.radians(A_degree))

B_x = B * math.cos(math.radians(B_degree))
B_y = B * math.sin(math.radians(B_degree))

ans = math.sqrt((A_x - B_x)**2 + (A_y - B_y)**2)

print(ans)

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())

x = abs((60*H+M)*0.5 - M*6)
theta = math.radians(x)

L = (A**2+B**2-2*A*B*math.cos(theta))**(1/2)
print(L)

Solution (Python):


import math




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



A_degree = H*60*(1/360) + M*(1/360)
B_degree = M*(1/30)
AB_degree = abs((A_degree - B_degree)) * math.pi

if AB_degree >= math.pi:
    AB_degree = 2*math.pi - AB_degree



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

print(d)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
degree_a = 30*h + m/2 
degree_b = 6*m 
x_a = a*math.sin(math.radians(degree_a))
y_a = a*math.cos(math.radians(degree_a))   
x_b = b*math.sin(math.radians(degree_b))
y_b = b*math.cos(math.radians(degree_b)) 
print(math.sqrt((x_a - x_b)**2 +(y_a - y_b)**2 ))

Solution (Python):
import math
A, B, H, M = map(int, input().split())
H = math.radians((H*60 + M)/2)
M = math.radians(M*6)

Ax = A*math.cos(H)
Ay = A*math.sin(H)
Bx = B*math.cos(M)
By = B*math.sin(M)

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

Solution (Python):
import math
A, B, H, M = map(int, input().split())
k = (60 * H - 11 * M)/2
if abs(k) > 180:
    cos = math.cos(math.radians(360-k))
else:
    cos = math.cos(math.radians(k))

a2 = A**2 + B**2 - 2* A* B* cos

print(a2**0.5)

Solution (Python):
import numpy as np
import math

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

a_angle = (60*h+m)/720*2*pi
b_angle = (m/60)*2*pi

angle = a_angle - b_angle

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

Solution (Python):
import math


def abs(num):
    if num < 0:
        return -num
    return num


def main():
    abhm = [int(_x) for _x in input().split()]
    HL = abhm[0]
    ML = abhm[1]
    H = abhm[2]
    M = abhm[3]

    radian = 2.0 * math.pi * abs(M / 60.0 - (H + M / 60.0) / 12.0)

    length = math.sqrt(HL * HL + ML * ML - 2 * HL * ML * math.cos(radian))
    print(length)


main()

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

theta_hour=math.pi/6*H+math.pi/6*M/60
theta_minute=math.pi/30*M
x=A**2+B**2-2*A*B*math.cos(abs(theta_hour-theta_minute))

print(math.sqrt(x))

Solution (Python):
import math

A, B, H, M = map(int, input().split())
minutes = H*60 + M
shortArg = 0.5 * minutes

longArg = 6 * M


arg = abs(shortArg - longArg)
C2 = A**2 + B**2 - 2 * A * B * math.cos(math.radians(arg))



print(C2**(1/2))

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


timePassed = 60 * H + M 

omega_a = 2*math.pi/(12*60) 
omega_b = 2*math.pi/(60) 

theta = omega_a * timePassed - omega_b*timePassed

if theta > math.pi:
    theta = 2 * math.pi - theta

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

print(f"{c:10}")

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

Solution (Python):
import math
A,B,H,M=list(map(int,input().split()))
r=math.radians(30*H-5.5*M)
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())
M_ras = math.radians(M * 6)
M_x = B * math.cos(M_ras)
M_y = B * math.sin(M_ras)
H_ras = math.radians(H * 30 + M * 0.5)
H_x = A * math.cos(H_ras)
H_y = A * math.sin(H_ras)
dis = math.sqrt((M_x - H_x) ** 2 + (M_y - H_y) ** 2)
print(dis)

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import radians, cos, sqrt
def main():
    a, b, h, m = map(int, input().split())

    jishin_degree = h * 30 + m * 0.5
    bushin_degree = m * 6
    kakudo = abs(jishin_degree - bushin_degree)

    r = sqrt(a**2 + b**2 - 2 * a * b * cos(radians(kakudo)))
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
import math

A, B, H, M = map(int, input().split())
h_rad = (H / 12 + M / 12 / 60)* 2 * math.pi
m_rad = M / 60 * 2 * math.pi
dif_rad = abs(h_rad - m_rad)
ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(dif_rad))
print(ans)

Solution (Python):

import math






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










kakudo_H = (H * 60 + M) / 720 * 360
kakudo_M = M / 60 * 360

print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(abs(kakudo_H - kakudo_M)))))

Solution (Python):

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


import math
thetah = 30*h+(m/60)*30
thetam = 6*m
theta=abs(thetah-thetam)
theta=min(theta,360-theta)
ans=math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(theta)))
print('{:.11f}'.format(ans))

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

thm = m/60 * 2* math.pi 
thh = (h*60 +  m)/720 * 2* math.pi


xm = b * math.cos(thm)
xh = a * math.cos(thh)

ym = b* math.sin(thm)
yh = a* math.sin(thh)

l=math.sqrt((xm-xh)**2 + (ym-yh)**2)
print(l)

Solution (Python):
import math

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

rad = math.pi * 2 * (h/12.0 + (m/60.0) / 12.0 - m/60.0)

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

print(ans)

Solution (Python):
import math

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

deg_H = 360*(H+M/60)/12
deg_M = 360*M/60

theta = math.radians(abs(deg_H - deg_M))

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

print(ans**0.5)

Solution (Python):
a,b,h,m=map(int,input().split())
x=abs(30*h-5.5*m)
y=min(x,360-x)
import math
rady=math.radians(y)
cosy=math.cos(rady)
c=(a**2+b**2-2*a*b*cosy)**0.5
print("{:.20}".format(c))

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

Solution (Python):

from math import cos, pi

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

t1 = 30 * H + M / 60 * 30
t2 = 6 * M
ans = A ** 2 + B ** 2 - 2 * A * B * cos(abs(t1 - t2) * pi / 180)
print(ans ** 0.5)

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

kk=h*30-5.5*m
if kk <0:
    kk+=360

import math
c= math.cos(math.radians(kk))

print((a*a+b*b-2*a*b*c)**0.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((H+M/60)*30-M*6)))**0.5)

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

def degh(H,M):
    bdeg=30
    return bdeg*(H+M/60)

import math
theta=math.radians(degh(H,M)-M*360/60)



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

Solution (Python):
import numpy as np

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

beta = 2*np.pi / 60 * float(m)
alpha = 2*np.pi / 12 * h + 2*np.pi /12 /60 * m
theta = abs(alpha - beta)

ans = np.sqrt((a - b*np.cos(theta))**2 + (b*np.sin(theta))**2)

print(ans)

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

Solution (Python):
import math

a, b, h, m = map(int, input().split())
ang_a = (360 * h / 12) + (0.5 * m)
ang_b = 360 * m / 60
ang = abs(ang_a - ang_b)

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
ang_a = (360 * h / 12) + (0.5 * m)
ang_b = 360 * m / 60
ang = abs(ang_a - ang_b if ang_a > ang_b else ang_b - ang_a)
ans = math.sqrt((a ** 2 + b ** 2) - (2*a*b*math.cos(math.radians(ang))))
print(ans)

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

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

Solution (Python):

def main():
    import sys
    import numpy as np

    input = sys.stdin.readline

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

    pi = np.pi
    time = 60 * H + M
    theta_H = (time * 2 * pi) / (12 * 60)
    theta_M = (M * 2 * pi) / 60
    res = abs(theta_H - theta_M)
    theta = min(res, 2 * pi - res)
    ans = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(theta))
    print(ans)


if __name__ == '__main__':
    main()

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

pi = math.pi

m_rad = 2 * pi * m / 60
h_rad = 2 * pi * h / 12 + 2 * pi / 12 * m / 60

"""
余弦定理： sqrt(a^2 + b^2 - 2abcosΘ)
cos(-Θ) = cos(Θ)
cos(2pi - Θ) = cos(Θ) 
"""

ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(m_rad - h_rad))
print("{:.12f}".format(ans))

Solution (Python):

import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]








a,b,h,m = MI()
min = 60*h+m
pi = math.pi
c = pi/30
d  = pi/360
jisin = (a*math.cos(min*c),a*math.sin(min*c))
hunsin = (b*math.cos(min*d),b*math.sin(min*d))
ans = (jisin[0]-hunsin[0])**2+(jisin[1]-hunsin[1])**2
print(ans**0.5)

Solution (Python):
import cmath
import math


if __name__ == '__main__':
    a, b, h, m = map(int, input().split())
    zh = cmath.rect(a, math.radians((60 * h + m) / 2))
    zm = cmath.rect(b, math.radians(m * 6))
    print(abs(zh - zm))

Solution (Python):
a,b,h,w=map(int,input().split())
import math
theta=math.radians(abs((h+w/60)*360/12-w*360/60))

c=(a**2+b**2-2*a*b*math.cos(theta))**0.5
print(c)

Solution (Python):
import math

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

xh = a*math.cos((60*h+m)/360*math.pi)
yh = a*math.sin((60*h+m)/360*math.pi)

xm = b*math.cos(m/30*math.pi)
ym = b*math.sin(m/30*math.pi)

print( ((xh-xm)**2+(yh-ym)**2)**0.5 )

Solution (Python):
import math

a, b, h, m = map(int, input().split())
rad_a = 2 * math.pi / 720 * (60 * h + m)
rad_b = 2 * math.pi / 60 * m

ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad_a - rad_b))
print("{:.20f}".format(ans))

Solution (Python):
import numpy as np

a, b, h, m = map(int, input().split())
rad_a = 2 * np.pi / 720 * (60 * h + m)
rad_b = 2 * np.pi / 60 * m

ans = np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(rad_a - rad_b))
print("{:.20f}".format(ans))

Solution (Python):
import numpy as np

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


def calc_rad(base, time):
    try:
        return 2 * np.pi * ((time) % base) / base
    except ZeroDivisionError:
        return 0


rad_a, rad_b = calc_rad(720, 60 * h + m), calc_rad(60, m)
ans = np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(rad_a - rad_b))
print("{:.20f}".format(ans))

Solution (Python):
import math
A, B, H, M = map(int,input().split())
t = 60*H + M
tb = (6*t)%360
ta = (360*t/(12*60))%360
c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(ta-tb)))
print(c)

Solution (Python):
import math

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

ang1 = (h%12+m/60) * 30
ang2 = m * 6
ang = abs(ang1-ang2)
if ang > 180:
    ang = 360 - ang

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

Solution (Python):
import math
A,B,H,M = map(int,input().split())
t1 = (30*H+M/2)*math.pi/180
x1 = A*math.cos(t1)
y1 = A*math.sin(t1)
t2 = M*math.pi/30
x2 = B*math.cos(t2)
y2 = B*math.sin(t2)
d = ((x1-x2)**2+(y1-y2)**2)**0.5
print(d)

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

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

ans = (A*A + B*B - 2*A*B*cos(abs(m-h))) ** 0.5
print(ans)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
import math
a,b,h,m = readInts()
h = h-12 if h>=12 else h
h_ = 30 * h + 30 * m/60
m_ = 360 * m / 60
kakudo = min(abs(m_ - h_), 360 - abs(m_ - h_))
c = pow(a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo)),.5)
print(c)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
angle = 30*H -5.5*M

CC = A**2 + B**2 - 2*A*B*math.cos(math.radians(angle))
print(CC**0.5)

Solution (Python):
import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    a, b, h, m = inl()
    t2 = 2 * math.pi * m / 60.0
    t1 = 2 * math.pi * (h * 60.0 + m) / (12 * 60.0)
    return math.sqrt(a * a + b * b - 2 * a * b * math.cos(t1 - t2))


print(solve())

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

dega = - 30*h - 0.5*m + 90
degb = - 6*m + 90

x_a = a*math.cos(math.radians(dega))
y_a = a*math.sin(math.radians(dega))
x_b = b*math.cos(math.radians(degb))
y_b = b*math.sin(math.radians(degb))


print(((x_a-x_b)**2+(y_a-y_b)**2)**0.5)

Solution (Python):
import math
A,B,H,M=map(int,input().split())
c=abs(H*30-M*5.5)
k=A*A+B*B-2*A*B*math.cos(c*math.pi/180)
l=math.sqrt(k)
print(l)

Solution (Python):
import math
score = list(map(int,input().split()))
minut = score[2]*60 + score[3]
jisin = math.radians(minut/2)
hunsin = math.radians(score[3]*6)
jixy = [math.cos(jisin)*score[0] , math.sin(jisin)*score[0]]
huxy = [math.cos(hunsin)*score[1] , math.sin(hunsin)*score[1]]

delx = abs(jixy[0] - huxy[0])
dely = abs(jixy[1] - huxy[1])

answer = (delx**2 + dely**2)**0.5
print(answer)

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

Solution (Python):
import math

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

theta_a = (60*h+m)/720*2*math.pi
theta_b = m/60*2*math.pi
theta_a_b = abs(theta_a-theta_b)

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

Solution (Python):
import math

a, b, h, m = map(int, input().split())
ht = (h*60+m)/360*math.pi
mt = m/30*math.pi
hx = a * math.sin(ht)
hy = a * math.cos(ht)
mx = b * math.sin(mt)
my = b * math.cos(mt)
print(math.sqrt((hx-mx)**2+(hy-my)**2))

Solution (Python):
import math

a,b,H,M = list(map(int,input().split()))

angle=abs((H*30+M/2)-M*6)/360*2*math.pi
print((a**2+b**2-2*a*b*math.cos(angle))**0.5)

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

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

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



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

Solution (Python):
import math
A, B, H, M = map(int, input().split())
a = math.pi/360 * (H*60 + M)
b = math.pi/30 * M
if abs(a - b) > math.pi:
    theta = 2 * math.pi - abs(a-b)
else:
    theta = abs(a-b)
L = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta))
print(L)

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

w_h = math.radians((h * 30) + (m * 0.5))
w_m = math.radians(m * 6)

x = (a ** 2) + (b ** 2) - (2 * a * b * math.cos(w_m - w_h))

print(math.sqrt(x))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
st = (60*h+m)/360*math.pi
lt = m/30*math.pi
sx = a*math.sin(st)
sy = a*math.cos(st)
lx = b*math.sin(lt)
ly = b*math.cos(lt)
print(math.sqrt((lx-sx)**2+(ly-sy)**2))

Solution (Python):
import math
a,b,h,m = map(int,input().split())
x_h = a * math.sin(math.radians(0.5 * (60 * h + m)))
y_h = a * math.cos(math.radians(0.5 * (60 * h + m)))
x_m = b * math.sin(math.radians(6 * m))
y_m = b * math.cos(math.radians(6 * m))

print(math.sqrt((x_h-x_m)**2 + (y_h-y_m)**2))

Solution (Python):
import math

def main():
    A, B, H, M = map(int, input().split())
    rad = math.pi * 2 * (H / 12 + (M / 60)/ 12 - M / 60)
    rsq = (A * A + B * B) - (2 * A * B) * math.cos(rad)
    print(math.sqrt(rsq))
main()

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

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

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

Solution (Python):
import math
inp = list(map(int,input().split()))
a = inp[0]
b = inp[1]
h = inp[2]
m = inp[3]

kakudo = min(((math.pi*h/6 + math.pi*m/360) - math.pi*m/30), 2*math.pi-((math.pi*h/6 + math.pi*m/360)-math.pi*m/30))

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

print(ans)