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


'''
時計の角度はいくつか？
長針は６０分で１回展（360度）回るので1分あたりに進む角度は、
360 / 60 = 6

よって、時間が6分だったら 6*6=36度回る

短針は12時間で1回展（360度）まわるので1分辺りに進む角度は
360 / (12*60) = 0.5 度回る
よって時間が6分だったら 6*0.5=3度回る
'''

longAngle  = M * 6
shortAngle = (H * 60 + M) * 0.5
Angle      = math.cos(math.radians(abs(longAngle - shortAngle)))


result = math.sqrt(A**2 + B**2 - 2*A*B*Angle)

print(result)

Solution (Python):
from math import *

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

deg1=30*h+0.5*m
deg2=6*m
c=a**2+b**2-2*a*b*cos(radians(deg1-deg2))

print(c**0.5)

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

Solution (Python):
import math

def main():
    a, b, h, m = (int(i) for i in input().split())

    rad = 2.0 * math.pi * ((h / 12) + (m / 60 / 12) - (m / 60))

    
    hx, hy = math.cos(rad) * a, math.sin(rad) * a
    mx, my = b, 0 

    
    d = math.sqrt((hx - mx)**2 + (hy - my)**2)
    print(d)


main()

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

Solution (Python):
import math

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

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

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

Solution (Python):
import math

if __name__ == "__main__":
    a, b, h, m = map(int, input().split())
    dm = m*6
    dh = h*30 + m/2
    d = math.fabs(dh - dm)
    d = a**2 + b**2 - 2*a*b*math.cos(math.radians(d))
    print("%.10lf"%math.sqrt(d))

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

m_ang = (360 / 60) * M
h_ang = (360 / (12 * 60)) * (60 * H + M)
deg = abs(m_ang - h_ang)
if deg > 180:
    deg = 360 - deg
deg = np.deg2rad(deg)

C2 = A**2 + B**2 - 2*A*B*np.cos(deg)
print(np.sqrt(C2))

Solution (Python):


import sys
import math

def main():
    input = sys.stdin.readline
    a, b, h, m = map(int, input().split())
    h_angle = h * 30 + m * 0.5
    m_angle = m * 6
    radian = 0
    if h_angle > m_angle:
        angle = h_angle - m_angle
    else:
        angle = m_angle - h_angle
    if angle > 180:
        angle = 360 - angle
    radian = math.radians(angle)
    c_2 = (a**2 + b**2) - (2 * a * b * math.cos(radian))
    print('{:.20f}'.format(math.sqrt(c_2)))
    return 


if __name__ == '__main__':
    main()

Solution (Python):
import math
A, B, H, M = map(int,input().split())
x1 = A * math.cos(math.radians(30*H+0.5*M))
y1 = A * math.sin(math.radians(30*H+0.5*M))
x2 = B * math.cos(math.radians(6*M))
y2 = B * math.sin(math.radians(6*M))
print(math.sqrt((x1-x2)**2+(y1-y2)**2))

Solution (Python):
import math

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

t=H+M/60
w_A=math.pi/6
w_B=math.pi*2

print(math.sqrt(A**2+B**2-A*B*2*math.cos((w_A-w_B)*t)))

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

Solution (Python):
import math

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

def angle():
  wa = 0.5
  wb = 6
  w = wb-wa
  t = H*60 + M
  wnew = (w*t)%360
  if wnew>=180:
    wnew = 360 - wnew
  return wnew


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

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


for i in range(1, 100, 2):
    pi += (-1) ** (i // 2) * (1 / 2 ** i + 1 / 3 ** i) / i
pi = pi * 4 

x = (30 * h + 0.5 * m - 6 * m) * pi / 180
ans = (a * a + b * b - 2 * a * b * math.cos(x))**0.5
print(ans)

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


for i in range(1, 100, 2):
    pi += (-1) ** (i // 2) * (1 / 2 ** i + 1 / 3 ** i) / i
pi = pi * 4 

x = (30 * h + 0.5 * m - 6 * m) * pi / 180

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
a_s = (30*h)%360+0.5*m
b_s = (6*m)

s = max(a_s,b_s)-min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
h_angle = (360 * h / 12) + 30 * m / 60
m_angle = 360 * m / 60
angle = abs(h_angle - m_angle)
aa = a * a + b * b - 2 * a * b * math.cos(math.radians(angle))
print(math.sqrt(aa))

Solution (Python):
import math

def main():
    a, b, h, m = map(int, input().split())
    mr = 6*m
    hr = 30*h+mr/12
    angle = math.radians(abs(mr-hr))
    ans = (a**2+b**2-2*a*b*math.cos(angle))**0.5
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import math
A,B,H,M = map(int,input().split())
h = H
m = M
if h >= 9:
  h -= 12
if m >= 45:
  h -= 60
a1 = math.pi/2 - (h/12+M/60/12)*2*math.pi
a2 = math.pi/2 - M/60*2*math.pi
d = math.sqrt((A*math.cos(a1)-B*math.cos(a2))**2+(A*math.sin(a1)-B*math.sin(a2))**2)

print(d)

Solution (Python):
data_pre=input().split()
data=[int(s) for s in data_pre]
A=data[0]
B=data[1]
H=data[2]
M=data[3]
import math
if math.fabs(H*30+M*0.5-M*6)<=180:
    theta=math.fabs(H*30+M*0.5-M*6)
else:
    theta=360-math.fabs(H*30+M*0.5-M*6)
cos=math.cos(math.radians(theta))
ans_2=A**2+B**2-2*A*B*cos
ans=ans_2**(1/2)
print(ans)

Solution (Python):
import math
import numpy as np

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

r_H = 360 * ((H + M / 60) / 12)
r_M = 360 * M / 60

r = np.abs(r_H - r_M)
r = min(r, 360 - r)

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

print(C)

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(H*30+M*0.5-M*6)))))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
bm = m * 360 / 60
ah = (h * 360 + bm) / 12
temp = ah - bm
temp = math.cos(math.radians(temp))
temp = a * a + b * b - 2 * a * b * temp
x = math.sqrt(temp)
print(x)

Solution (Python):
import numpy as np
import math




def main():
    A,B,H,M = map(int, input().split())
    
    h = H + M/60
    
    hr = (h%12)/12 * 2*math.pi
    
    m = M/60
    
    mr = m * 2*math.pi

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

main()

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

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

theta1 = 2*pi*((H*60+M)/720)
theta2 = 2*pi*(M/60)

X = [A*cos(pi/2-theta1), A*sin(pi/2-theta1)]
Y = [B*cos(pi/2-theta2), B*sin(pi/2-theta2)]

print(sqrt((X[0]-Y[0])**2 + (X[1]-Y[1])**2))

Solution (Python):
import math
from decimal import Decimal

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

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

print(ans)

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

a_ang = (h/12 + (1/12)*(m/60))*2*math.pi
b_ang = (m/60)*2*math.pi
ax = a*math.cos(a_ang)
bx = b*math.cos(b_ang)
ay = a*math.sin(a_ang)
by = b*math.sin(b_ang)

x = ax - bx
y = ay - by
ans = (x**2+y**2)**0.5
print(ans)

Solution (Python):
import math

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

hAngle = 360*((h/12) + (1/12) * (m/60))
mAngle = 360*(m/60)

angle = abs(hAngle - mAngle)

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

print(math.sqrt(c))

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

import math

t = 60 * h + m
a_angle = t * (1/2)
b_angle = t * 6
diff_angle = abs(a_angle - b_angle)

x = a**2 +b**2 - 2 * a * b * math.cos(math.radians(diff_angle))


print(math.sqrt(x))

Solution (Python):

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

angle_H = (H + (M/60)) * 360 / 12
angle_M = M * 360 / 60
angle = angle_H - angle_M
a = A * math.sin(math.radians(angle))
b = B - A * math.cos(math.radians(angle))
distance = math.sqrt( a** 2 + b ** 2 )
print(distance)

Solution (Python):
import math
A,B,H,M=input().split()
print(math.sqrt(int(A)**2+int(B)**2-
               (2*int(A)*int(B)*math.cos(math.radians(math.fabs(int(M)*6.0-int(H)*30-int(M)*0.5))))))

Solution (Python):

import math

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

pi = math.pi

mrad = 2 * pi * m / 60
mpos = (a * math.sin(mrad), a * math.cos(mrad))

hrad = 2 * pi * (h * 60 + m) / 720
hpos = (b * math.sin(hrad), b * math.cos(hrad))

ans = math.sqrt((mpos[0] - hpos[0]) ** 2 + (mpos[1] - hpos[1]) ** 2)
print(ans)

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

Solution (Python):
import math

A,B,H,M = (int(a) for a in input().split())
h = H * 30 + M/2
m = 6 * M
a = abs(h-m)
x = min(a,360-a)
t = math.cos(x*(math.pi)/180)
print(math.sqrt(A**2 + B**2 - 2*A*B*t))

Solution (Python):
import math

mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    a, b, h, m = map(int,input().split())
    
    min_pos = (m / 60) * 360
    
    hr_pos = (h / 12) * 360
    
    hr_pos += (m / 60) * (360 / 12)
    
    
    
    deg = abs(hr_pos - min_pos)
    
    if deg > 180:
        deg = 360 - deg
    
    
    
    
    
    
    rad = math.radians(deg)
    
    
    
    ans = math.sqrt((a ** 2) + (b ** 2) - (2 * a * b * math.cos(rad)))
    
    print(ans)
    
        
    
    

main()

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

Solution (Python):
import numpy as np
A, B, H, M = map(int, input().split())
Pi = np.pi
thetaH = 2*Pi*H/12 + Pi/6*M/60
thetaM = 2*Pi*M/60

xH = A*np.sin(thetaH)
yH = A*np.cos(thetaH)

xM = B*np.sin(thetaM)
yM = B*np.cos(thetaM)

dd = np.sqrt((xH-xM)**2+(yH-yM)**2)

print(dd)

Solution (Python):
import math

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

M_range = 6 * M
H_range = 30 * H + 0.5 * M

angle = abs(M_range - H_range)
if angle > 180:
    angle = 360 - angle

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

print(math.sqrt(ans))

Solution (Python):
import math
def Ii():return int(input())
def Mi():return map(int,input().split())
def Li():return list(map(int,input().split()))

a,b,h,m = Mi()
rad = math.pi*abs(h/6 + m/360 - m/30)


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

print(math.sqrt(c))

Solution (Python):
import cmath
import math
ph = math.pi
A, B, H, M = map(float, input().split())
Aarg = 2*ph*H/12
Aarg += 2*ph*M/720

Barg = 2*ph*M/60




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

Solution (Python):
import math

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

x = abs((h*60 + m) * 5.5)
x = x % 360

ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(x)))**(1/2)

print(ans)

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

l = (6*m + 6*60*h) % 360
s = (m/2 + 60*h/2) % 360

c = math.radians(abs(l-s))
ans = a**2 + b**2 - 2*a*b*math.cos(c)
print(ans**0.5)

Solution (Python):
import math

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

sh=math.pi*(H+M/60)/6
sm=math.pi*M/30

s=abs(sh-sm)

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

print(C)

Solution (Python):
import numpy as np


a, b, h, m = map(int, input().split())
theta = np.abs(((h+m/60) * 5 / 60 - m / 60) * 2 * np.pi)
theta = min(theta, 2 * np.pi - theta)
d = np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(theta))
print(d)

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

import math

minute = math.pi*2*M/60
hour = math.pi*2*H/12 + math.pi*(1/6)*M/60

cos = math.cos(abs(hour-minute))

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

print(ans)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
x = abs((60 * h + m) / 2 - m * 6)
c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(x))
c = math.sqrt(c2)
print(c)

Solution (Python):
A,B,H,M = map(int,input().split())
import math
minute = 6 * M
hour = 30 * (H + M / 60)
a = abs(minute - hour)
degree = min(a, 360 - a)
rad = math.radians(degree)
cosa = math.cos(rad)
C = A ** 2 + B ** 2 - 2 * A * B * cosa
print(C ** 0.5)

Solution (Python):
import math

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

h_angle = (h + m / 60) / 12
m_angle = m / 60

angle = (h_angle - m_angle) * 2 * math.pi

distance = float(a ** 2) + float(b ** 2) - 2 * a * b * math.cos(angle)

print(math.sqrt(distance))

Solution (Python):
import math

pi = math.pi
a = input()
a = a.split()
A = float(a[0])
B = float(a[1])
H = float(a[2])
M = float(a[3])
Ab = H*5 + 5/60*M
Ar = 2*pi * Ab / 60
Br = 2*pi * M / 60
if Ar > Br:
    Cr = Ar - Br
else:
    Cr = Br - Ar
if Cr > pi:
    Cr = 2*pi - Cr
ans = A**2 + B**2 - 2*A*B*math.cos(Cr)
print(math.sqrt(ans))

Solution (Python):


import sys
stdin = sys.stdin
import math

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    a, b, h, m = na()
    theta1 = 2 * math.pi * (m/60)
    theta2 = 2 * math.pi * ((h*60+m)/720)
    theta = min(abs(theta1 - theta2), abs(theta2 - theta1))
    d = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta))
    print("{:.10f}".format(d))

if __name__ == "__main__":
    main()

Solution (Python):
import math

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

harg = (math.pi * 2 / 12) * (H + M / 60.)
marg = (math.pi * 2 / 60) * M

hx = A * math.cos(harg)
hy = A * math.sin(harg)

mx = B * math.cos(marg)
my = B * math.sin(marg)

print(math.sqrt((hx - mx) ** 2 + (hy - my) ** 2))

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

Solution (Python):
import math

A,B,H,M = map(int,input().split())
Hd = 2*math.pi*H/12 + 30/360*2*math.pi*M/60
Md = 2*math.pi*M/60
Hx = A*math.cos(Hd)
Hy = A*math.sin(Hd)
Mx = B*math.cos(Md)
My = B*math.sin(Md)
r = ((Hx - Mx)**2 + (Hy - My)**2)**0.5
print(r)

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

Solution (Python):
import numpy as np
A, B, H, M = map(int, input().split())
theta_A = 30 * H + 0.5 * M
theta_B = (6 * M) % 360
theta = (theta_A - theta_B) * np.pi / 180
print(np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(theta)))

Solution (Python):
import math 

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

h=60*60*h
m=60*m

d=(h+m)/120-m/10

theta=math.pi*d/180

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

Solution (Python):

from math import pi,cos,sin

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


degree_A = (H*60+M) * (2*pi/(12*60))
degree_B = M * (2*pi/60)

degree_AB = min( abs(degree_A - degree_B) , (2*pi - abs(degree_A - degree_B)) )

ans = ( A**2 + B**2 - 2*A*B*cos(degree_AB) )**0.5
print(ans)

Solution (Python):

from math import pi,cos,sin

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


degree_A = (H*60+M) * (2*pi/(12*60))
degree_B = M * (2*pi/60)

x_A = A * cos(degree_A)
y_A = A * sin(degree_A)

x_B = B * cos(degree_B)
y_B = B * sin(degree_B)

ans = ( (x_A - x_B)**2 + (y_A - y_B)**2 )**0.5
print(ans)

Solution (Python):
import math

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

total_m = H * 60 + M
theta_radians = (abs(12 * M - total_m)) / 2
ans_2 = A**2 + B**2 -2*A*B*(math.cos(math.radians(theta_radians)))
ans = math.sqrt(ans_2)

print(ans)

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

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

Solution (Python):
import math

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

sh=math.pi*(H+M/60)/6
sm=math.pi*M/30

s=abs(sh-sm)

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

print(C)

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

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

Solution (Python):
import math

A,B,H,M = map(int,input().split())
theta1 = (30*H)+(0.5*M)
theta2 = 6*M

theta = min(abs(theta1-theta2),360-abs(theta1-theta2))
X = math.sqrt((A**2)+(B**2)-(2*A*B*math.cos(math.radians(theta))))

print(X)

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

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

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

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

ans = (a**2 + b**2 -2*a*b*math.cos(2*math.pi*(h/12 + m/60/12 - m/60)))**(1/2)
print("%.10f" % ans)

Solution (Python):
import numpy as np

A, B, H, M = map(float, input().split())
Time = H + M / 60.
ang = Time * 330.

C = np.sqrt(A**2 + B**2 -2*A*B*np.cos(np.radians(ang)))

print(C)

Solution (Python):
from math import pi, cos,  sqrt
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))

Solution (Python):



import math

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

minute_h=60*h+m

rad_a=math.pi*minute_h/360
rad_b=math.pi*m/30
rad_dif=abs(rad_a-rad_b)

d=(a**2+b**2-2*a*b*math.cos(rad_dif))**0.5
print(d)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
degree = abs(h * 30 + 0.5 * m - m * 6)
degree = min(degree, abs(360 - degree))
theta = math.radians(degree)
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())
d=M/2
x = (H*5*6+d- M*6)*math.pi/180
c=(A*A + B*B - 2*A*B* math.cos(x))**(1/2)
print(c)

Solution (Python):
import math
 
a,b,h,m=map(int, input().split())
 
h_kaku=(2*math.pi*(h+m/60))/12
m_kaku=(2*math.pi*m)/60
 
h_x=a * math.cos(-h_kaku+math.pi/2)
h_y=a * math.sin(-h_kaku+math.pi/2)
 
m_x=b * math.cos(-m_kaku+math.pi/2)
m_y=b * math.sin(-m_kaku+math.pi/2)
 
nagasa=math.sqrt((h_x-m_x)**2+(h_y-m_y)**2)
print(nagasa)

Solution (Python):
import math

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

h_kaku=(2*math.pi*(h+m/60))/12
m_kaku=(2*math.pi*m)/60

h_x=a * math.cos(-h_kaku+math.pi/2)
h_y=a * math.sin(-h_kaku+math.pi/2)

m_x=b * math.cos(-m_kaku+math.pi/2)
m_y=b * math.sin(-m_kaku+math.pi/2)

nagasa=math.sqrt((h_x-m_x)**2+(h_y-m_y)**2)

print(nagasa)

Solution (Python):
import math
from decimal import Decimal
from sys import stdin
data = stdin.readline().rstrip()

a = Decimal(data.split()[0])
b = Decimal(data.split()[1])

h = int(data.split()[2])
m = int(data.split()[3])

h_angle = Decimal(30*h + 0.5*m)
m_angle = Decimal(6*m)

dis = abs(h_angle - m_angle)
if 180 < dis <= 360:
    dis = 360 - dis

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
rad_a = 360 * h / 12 + 30 * m / 60
rad_b = 360 * m / 60 

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

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

rad_a = 360 * h / 12 + 30 * m / 60
rad_b = 360 * m / 60 
  
if rad_a >= rad_b:
  ans = a**2 + b **2 - 2*a*b*math.cos(math.radians(rad_a - rad_b))
  print(math.sqrt(ans))
else:
  ans = a**2 + b **2 - 2*a*b*math.cos(math.radians(rad_b - rad_a))
  print(math.sqrt(ans))

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

short = (h*30 + m*0.5) % 360
long = m*6
C = abs(long - short)

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

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

short = (h*30 + m*0.5) % 360
long = m*6
C = abs(long - short)

print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(min(C,360 - C)))))

Solution (Python):
import math

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

pi = math.pi
rad_per_min_A = 2*pi/12/60
rad_per_min_B = 2*pi/60

m = H*60+M

rad_A = m*rad_per_min_A
rad_B = M*rad_per_min_B

Ax = A*math.cos(rad_A)
Ay = A*math.sin(rad_A)
Bx = B*math.cos(rad_B)
By = B*math.sin(rad_B)

L = ((Ax-Bx)**2+(Ay-By)**2)**0.5
print(L)

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

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

Solution (Python):
import math

A, B, H, M = map(int, input().split())
thita = math.radians(abs(M*360/60 - (H*360/12 + M*360/12/60)))

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

Solution (Python):
a,b,h,m=map(int, input().split())
ang_a=(360/12)*h+30*m/60
ang_b=(360/60)*m
ang=abs(ang_a-ang_b)
if ang>180:
  ang=360-ang
else:
  ang=ang

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

Solution (Python):
a,b,h,m=map(int, input().split())
ang_a=(360/12)*h+30*m/60
ang_b=(360/60)*m
ang=abs(ang_a-ang_b)
if ang>180:
  ang=360-ang
else:
  ang=ang

import math
cosA=math.cos(math.radians(ang))
ans=(a**2+b**2-2*a*b*cosA)**0.5
print(f'{ans:.09f}')

Solution (Python):
import math

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

H_0 = H+N/60
N_0 = N/5
Z = H_0-N_0

if Z>6:
  angle = (12-Z)*30
else:
  angle = Z*30
  


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



a_angle = h/12 + m*1/12/60

b_angle = m/60



angle = abs(a_angle - b_angle)*2*math.pi



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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
from math import ceil, floor, log2, sin, cos, radians, sqrt






def solve():
    A, B, H, M = MI()

    hour = 0
    for i in range(12):
        min = 0
        for j in range(60):
            if i == H and j == M:
                
                

                x1, y1 = A * cos(radians(hour)), A * sin(radians(hour))
                x2, y2 = B * cos(radians(min)), B * sin(radians(min))

                x = abs(x1 - x2)
                y = abs(y1 - y2)
                print(sqrt(x**2 + y**2))

            hour += 0.5
            min += 6


if __name__ == '__main__':
    solve()

Solution (Python):
import math

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

c = (h - 11 / 60 * m) / 6 * math.pi

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

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

hour = (h + m/60) / 12
minute = m / 60
if  abs(hour - minute) <= 0.5:
    x = abs(hour-minute)
else:
    x = 1 - abs(hour-minute)
cc = a * a + b * b -2 * a * b * math.cos(2 * math.pi * x)
print(math.sqrt(cc))

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

Solution (Python):
import math

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

hour_angle=0.5*(60*h+m)
minute_angle=6*m

diff_angle=abs(hour_angle-minute_angle)

angle=min(360-diff_angle,diff_angle)
cos_angle=math.cos(angle*(math.pi/180))

lenth=math.sqrt(a**2+b**2-(2*a*b*cos_angle))
print(lenth)

Solution (Python):
import math

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




aA = 30*H+M/2


aB = 6*M
kakudo = aA - aB


if kakudo >= 180:
    kakudo = 360 - kakudo





ans = 0
ans2 = 0  
ans2 = A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo))

ans = math.sqrt(ans2)


print(ans)

Solution (Python):
import math

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

degreeL = (30 * H + 0.5 * M)*math.pi/180

degreeS = M * 6 * math.pi/180


d = abs(degreeL - degreeS)

degree = min (d, 360- d)

if degree == 90:
    length = math.sqrt(A**2 + B**2)
elif degree == 180:
    length == A + B
else:
    length = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(degree))
print(length)

Solution (Python):
import math

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

tha = (360 / 12 * h + 360 / 12 / 60 * m) * math.pi / 180
thb = (360 / 60 * m) * math.pi / 180

c2 = a**2 + b**2 - 2*a*b*math.cos(tha - thb)

print(c2**(1/2))

Solution (Python):
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2, cos, pi
from fractions import Fraction



















hrhand, minhand, hr, minut = map(int, stdin.readline().split())

angmin =360*minut/60
anghr =360*(hr + minut/60)/12


totang = abs(angmin - anghr)


print((hrhand**2 + minhand**2 - 2*hrhand*minhand*cos(totang*pi/180))**0.5)

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

rad = 2 * math.pi * (((C / 12)+((5 / 60)*(D / 60))) - (D /60))

if math.cos(rad) == 1:
    print(abs(A - B))
elif math.cos(rad) == -1:
    print(A + B)
else:
    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())

degH = H*360/12 + M*360/12/60
degM = M*360/60

angle = abs(degH-degM)

dist = (A**2 + B**2 - 2*A*B * math.cos(math.radians(angle)))**(1/2)

print(dist)

Solution (Python):
import sys
import math

a, b, h, m = tuple(map(int, sys.stdin.buffer.read().split()))

mm = m / 60
hh = (h + mm)  / 12
r = (mm - hh) * math.pi * 2

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())
tH = 30*H + 0.5*M
tM = 6*M

sa = tH - tM

if sa <0:
    sa*=-1

def cos(theta):
    hm = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta)))
    return hm

if sa > 180:
    print(cos(360-sa))
elif sa < 180:
    print(cos(sa))
elif sa == 180:
    print(A+B)
else:
    print(B-A)

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

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

Solution (Python):
import math

A,B,H,M = map(int,input().split())
C2 = A**2+B**2-2*A*B*math.cos(math.radians(abs((30*H+M*0.5)-6*M)))
print(C2**0.5)

Solution (Python):
import math

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

theta = (330*math.pi*(h + m/60))/180

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

print(ans)

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

y = (a * math.sin(math.radians(360 * (h + m/60) / 12))) - (b * math.sin(math.radians(360 * m / 60)))
x = (a * math.cos(math.radians(360 * (h + m/60) / 12))) - (b * math.cos(math.radians(360 * m / 60)))
ans = math.sqrt(x**2+y**2)
print(ans)

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

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

pi = 3.141592653589793238
tmp = abs(m*6-(h*30+m/2))
arg = min(tmp, 360-tmp)

print(sqrt(a**2+b**2-2*a*b*cos(arg*pi/180)))

Solution (Python):
import math
import numpy as np
h_len,s_len,h_time,s_time = map(int,input().split())

h_time = h_time%12
h_rad = ((h_time*60 + s_time)/720.0)*360
s_rad = (s_time/60.0)*360
sub_rad = abs(h_rad-s_rad)
if sub_rad%180!= 0 and sub_rad >= 180:
    sub_rad -= 360





obj_len = h_len**2 + s_len**2 - 2*h_len*s_len*math.cos(math.radians(sub_rad))
print(np.sqrt(obj_len))

Solution (Python):
a,b,h,m = map(float,input().split())
import math
r_h = (h * (360.0/12)+(0.5*m))
r_m = (m * (360.0/60))
r = min(math.fabs(r_h-r_m),math.fabs(r_m-r_h))

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

Solution (Python):
from math import cos, radians

a, b, h, m = map(int, input().split())
d0 = m * 6
d1 = (h * 60+m) * 0.5
ans = a ** 2 + b ** 2 - 2 * a * b * cos(radians(abs(d1 - d0)))
ans **= 0.5
print(ans)

Solution (Python):








def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))



import math


def main():
	a,b,h,m=MI()

	x=a*math.cos(2*math.pi*(h+m/60)/12)
	y=a*math.sin(2*math.pi*(h+m/60)/12)
	xx=b*math.cos(2*math.pi*m/60)
	yy=b*math.sin(2*math.pi*m/60)

	

	xxx=x-xx
	yyy=y-yy

	

	print((xxx**2+yyy**2)**0.5)
















if __name__ == "__main__":
	main()

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

def calc(a, b, h, m):
    theta = 2 * pi * (h / 12 + m / 60 / 12 - m / 60)
    c2 = a ** 2 + b ** 2 - 2 * a * b * cos(theta)
    return sqrt(c2)

A, B, H, M = map(int, input().split())
res = calc(A, B, H, M)
print('{:.12f}'.format(res))

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

A, B, H, M = map(int, input().split())
rad = 0 if H==0 and M==0 else radians(abs(360/(720/(60*H+M))-6*M))
ans = sqrt((A**2)+(B**2)-2*A*B*cos(rad))
print(ans)

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