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())
s=math.radians((60*h+m)/2)
l=math.radians(6*m)
d2=(a*math.sin(s)-b*math.sin(l))**2+(a*math.cos(s)-b*math.cos(l))**2
d=math.sqrt(d2)
print(d)

Solution (Python):
import math

a,b,h,m=map(float,input().split())
pi=math.pi
apos=(h*60+m)/(12*60)*2*pi
bpos=m/60*2*pi

kaku=apos-bpos

if kaku<0:
    kaku=-kaku
if kaku>=pi:
    kaku=2*pi-kaku

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

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

Solution (Python):
import math
A,B,H,M=map(int,input().split())
angA=math.radians(90-((H+M/60.0)/12.0)*360)
angB=math.radians(90-(M/60.0)*360)
ax=A*math.cos(angA)
ay=A*math.sin(angA)
bx=B*math.cos(angB)
by=B*math.sin(angB)
dis=math.sqrt((ax-bx)**2+(ay-by)**2)
print(dis)

Solution (Python):
import math

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

long_r = (math.pi * 2 * H / 12) + (math.pi * 2 * M / 720)
short_r = math.pi * 2 * M / 60

sin_l = math.sin(long_r)
cos_l = math.cos(long_r)
sin_s = math.sin(short_r)
cos_s = math.cos(short_r)

yl = sin_l * A
xl = cos_l * A
ys = sin_s * B
xs = cos_s * B

diff = (yl - ys) * (yl - ys) + (xl - xs) * (xl - xs)
print(math.sqrt(diff))

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

Solution (Python):
from math import radians, cos

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

angle_h = (H + M/60) * 30
angle_m = M * 6
theta = min(abs(angle_h-angle_m), 360 - abs(angle_h-angle_m))
r2 = A**2 + B**2 - 2*A*B*cos(radians(theta))
print(r2**(1/2))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
zisin = 30*h + 0.5*m
hunnsinn = 6*m
diff = abs(zisin-hunnsinn)

c2 = a**2 + b**2 -2*a*b*math.cos(math.radians(diff))
print(pow(c2, 0.5))

Solution (Python):
import math

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

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

if r >= 180:
    r = 360 - r

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

print(math.sqrt(ans))

Solution (Python):
import math
a, b, h, m = list(map(float ,input().split(' ')))
pi = math.pi
x, y = pi*h/6 + m*pi/360, pi*m/30

res = math.sqrt(a**2 + b**2 - 2*a*b*(math.cos(x-y)))
print(res)

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



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


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

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

Solution (Python):
import math

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


H_rad = (H * 30 + M * 0.5) % 360
M_rad = M * 6

rad = abs(M_rad-H_rad)

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

print(math.sqrt(ans))

Solution (Python):
import math
a,b,h,m = map(int,input().split())
zisin = (h * 60 + m) / 2
hunsin = m * 6
xzahyou = ((math.sin(math.radians(zisin)))*a - (math.sin(math.radians(hunsin)))*b) ** 2
yzahyou = ((math.cos(math.radians(zisin)))*a - (math.cos(math.radians(hunsin)))*b) ** 2
print((xzahyou + yzahyou) ** (1/2))

Solution (Python):
import numpy as np
def input_one_number():
    return int(input())
 
def input_multiple_number():
    return map(int, input().split())
 
def input_multiple_number_as_list():
    return list(map(int, input().split()))

a,b,h,m=input_multiple_number()

rad=np.deg2rad(min(abs(h*30-m*5.5),360-(abs(h*30-m*5.5))))

ans=np.sqrt(pow(a,2)+pow(b,2)-2*a*b*np.cos(rad))
print(ans)

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

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

t = M+60*H

pos_h = (A*cos(pi/2-2*pi*t/720), A*sin(pi/2-2*pi*t/720))
pos_m = (B*cos(pi/2-2*pi*t/60), B*sin(pi/2-2*pi*t/60))


print(sqrt((pos_h[0]-pos_m[0])**2+(pos_h[1]-pos_m[1])**2))

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

import math
hkaku=0
mkaku=0

hkaku=(H%12)*30+M/2
mkaku=M*6
kaku=abs(hkaku-mkaku)


if kaku > 180:
    kaku=360-kaku
C=A**2+B**2-2*A*B*math.cos(math.radians(kaku))
C=C**(1/2)
print(C)

Solution (Python):
import numpy as np

def rot(theta, vec):
    theta = np.deg2rad(theta)
    affine = np.array([[np.cos(theta), -np.sin(theta)],
    [np.sin(theta), np.cos(theta)]])

    return np.dot(affine, vec)


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


unit_h = 360 / (12 * 60)
unit_m = 360 / 60

h_angle = unit_h * (60 * H + M)
m_angle = unit_m * M

h_vec = np.array([0, A])
m_vec = np.array([0, B])

h_vec = rot(h_angle, h_vec)
m_vec = rot(m_angle, m_vec)

print(np.linalg.norm(h_vec - m_vec, ord=(2)))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
w_m = m*(360/60)*(math.pi/180)
w_h = (h + m/60)*(360/12)*(math.pi/180)

d = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(w_h - w_m))
print(d)

Solution (Python):
import math
A, B, H, M = list(map(int, input().split()))
deg_l = 6 * M
deg_s = 30 * H + 0.5 * M
deg = abs(deg_l - deg_s)
cos = math.cos(math.radians(deg))
ans = math.sqrt((A**2) + (B**2) - (2*A*B*cos))
print(ans)

Solution (Python):
import math


def solve():
    A, B, H, M = map(int, input().split())
    H = (H*60+M)*0.5
    M *= 6
    radio = 0
    if abs(H-M) <= 360-abs(H-M):
        radio = abs(H-M)
    else:
        radio = 360-abs(H-M)
    ans = A**2+B**2-2*A*B*math.cos(math.radians(radio))
    print(ans**0.5)


solve()

Solution (Python):
import math
A, B, H, M = map(int, input().split())
theta_A = 2*math.pi*((H+M/60)/12)
theta_B = 2*math.pi*M/60
A_x = A*math.cos(theta_A)
A_y = A*math.sin(theta_A)
B_x = B*math.cos(theta_B)
B_y = B*math.sin(theta_B)
dst = math.sqrt((A_x-B_x)**2+(A_y-B_y)**2)
print(dst)

Solution (Python):

import math

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

sec = H * 3600 + M * 60

arg = abs(math.pi * 11 * sec / (6 * 3600))

arg = min(arg, 2 * math.pi - arg)

cos = math.cos(arg)

x = (A ** 2 + B ** 2 - 2 * A * B * cos) ** 0.5

print("{}".format(x))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
an = m*0.5+((12+h)%12)*30
bn = m*6
max = -1
min = -1
if an >= bn:
    max = an
    min = bn
else:
    max = bn
    min = an
c = max-min
rad = math.radians(c)
ans = a**2+b**2-2*a*b*math.cos(rad)
ans = math.sqrt(ans)
print(ans)

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

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

k_a = 0.5*m + 30*h
k_b = 6*m
c = math.radians(abs(k_a-k_b))
l = (a**2+b**2-2*a*b*math.cos(c))**.5
print(l)

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

h_tip_rad=(60*H+M)*2*np.pi/12/60
m_tip_rad=M*np.pi/30

rad=abs(m_tip_rad-h_tip_rad)

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

print(ans)

Solution (Python):

import math 
ip = [int(i) for i in input().split()]
a = ip[0]
b = ip[1]
h = ip[2]
m = ip[3]


lng =  30 * (h + m/60) 
sht = 6 * m

x = abs(lng - sht)

y = math.cos(math.radians(x))

shen = math.sqrt(a*a + b*b - 2*a*b*y)


print(shen)

Solution (Python):

import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  
  sys.stderr.write(_s+"\n")

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

hDeg = (30 * h) + (0.5 * m)
mDeg = (6 * m)


import math

rad = math.radians( abs(hDeg - mDeg) )

p(hDeg, mDeg, rad)

ans = pow( pow(a,2) + pow(b,2) - 2*a*b*math.cos(rad), 1/2)

print(ans)

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

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

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

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


    ans = sqrt(A**2 + B**2 - 2*A*B*cos(a-b))
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):

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

import math
short = 30 * h 
long = 6 * m 
short = 30 * h + m*30/60
ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(abs(short-long))))**(1/2)
print(ans)

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

def main():
    import math as m
    A, B, H, M = map(int, read().split())
    theta = ((360/60)*M/180)*m.pi
    phi = ((360/720)*(H*60+M)/180)*m.pi
    ans = abs(m.sin(theta)*B - m.sin(phi)*A)**2 + abs(m.cos(theta)*B - m.cos(phi)*A)**2
    ans = m.sqrt(ans)
    print(ans)
    return

if __name__ == '__main__':
    main()

Solution (Python):
import math

hour_hand_len, min_hand_len, later_hour, later_min = list(map(int, input().split()))

h_ang = 30 * (later_hour + (later_min / 60))
min_ang = 6 * later_min

ang = min(abs(360 - abs(h_ang - min_ang)), abs(h_ang - min_ang))
print(
    math.sqrt(
        (hour_hand_len ** 2)
        + (min_hand_len ** 2)
        - (2 * hour_hand_len * min_hand_len * math.cos(math.radians(ang)))
    )
)

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

hour =  min * 0.5
minute = m * 6
open = abs(hour-minute)

if open > 180:
    open = 360 - open 

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

print(c)

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

t = 60*h + m
ji = t/2
hun = 6*m
theta = abs(ji-hun)
c = math.cos(math.radians(theta))

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

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

a = 30 * (H%12) + 0.5 * M
b = 6 * M

degree = min(abs(a-b), 360 - abs(a-b))
ans = A**2 + B ** 2 - 2*A*B*math.cos(math.radians(degree))


print(ans**0.5)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
ji_kaku = 30 * h + 0.5 * m
hun_kaku = 6 * m
sa1 = ji_kaku - hun_kaku
sa2 = hun_kaku + (360 - ji_kaku)
sa = min(sa1, sa2)

resres = (a * a) + (b * b) - (2 * a * b * math.cos(math.radians(sa)))
res = math.sqrt(resres)

print(abs(res))

Solution (Python):
import math

a, b, h, m = (int(x) for x in input().split())

ans = 0

angle = 0

angle_ji = h * 30 + 0.5 * m
angle_fun = 6 * m

angle = angle_ji - angle_fun

if 180 < angle :
    angle = 360 - angle 

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

ans = x**(1/2)

print(ans)

Solution (Python):
import math

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

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

mn = abs(hp - mp)
if mn > 180:
    mn = 360 - mn

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

print(a)

Solution (Python):
import sys
import math

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

pi=3.141592653589793238


ha=(h+(m/60))/6
hb=m/30

agl=abs(pi*(ha-hb))

hh=(a**2+b**2-2*a*b*math.cos(agl))**0.5

print(hh)

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

a_theta = (h / 12 + m / 720) * 2 * math.pi
b_theta = m / 60 * 2 * math.pi

a_cos = a * math.cos(a_theta)
a_sin = a * math.sin(a_theta)
b_cos = b * math.cos(b_theta)
b_sin = b * math.sin(b_theta)

print(math.sqrt(math.pow(a_cos - b_cos, 2) + math.pow(a_sin - b_sin, 2)))

Solution (Python):
from math import pi, cos

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

h += m / 60

alpha = 2 * pi * abs(h / 12 - m / 60)

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

print(ans)

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

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

theta = abs(((h / 12) * 360) + (m / 60 / 12 * 360) - (m / 60 * 360))
theta = radians(theta)
res = sqrt(a**2 + b**2 -2*a*b*cos(theta))
print(res)

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

import numpy as np
if m == 0:
    b_ang = 0
    if h == 0:
        a_ang = 0
    else:
        a_ang = np.pi * 2 * (h + m/60) / 12
else:
    a_ang = np.pi * 2 * (h + m / 60) / 12
    b_ang = np.pi * 2 / 60 * m


ang = np.abs(a_ang - b_ang)

ang = min(ang, 2*np.pi - ang)


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

Solution (Python):
import math

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

if H >= 5 * M:
    theta = 30 * H - 5.5 * M
else:
    theta = 5.5 * M - 30 * H

if theta > 180:
    theta = 360 - theta

cos_theta = math.cos(math.radians(theta))

a = A ** 2 + B ** 2 - 2 * A * B * cos_theta

print(math.sqrt(a))

Solution (Python):
import math

a,b,h,m = (int(x) for x in input().split())

xa = a*math.sin(math.pi * m /30)
ya = a*math.cos(math.pi * m /30)
xb = b*math.sin((math.pi * h /6) + (math.pi * m /360))
yb = b*math.cos((math.pi * h /6) + (math.pi * m /360))

print(math.sqrt((xa - xb)**2 + (ya - yb)**2))

Solution (Python):




import sys
from io import StringIO
import unittest
import math

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b,h,m=map(int, readline().rstrip().split())
    xxx=abs((((h+m/60)/12)*360)-((m/60)*360))
    xxx=min(xxx,360-xxx)
    rad=math.radians(xxx)
    cc=a*a+b*b-2*a*b*math.cos(rad)
    print(math.sqrt(cc))
    
    
    
    
    

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Solution (Python):
import math

a,b,h,m=list(map(int,input().split()))
short=h*30+30*(m/60)
long=m*6
angle=abs(long-short)

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

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

theta_A = (H*60+M)*2*math.pi/(12*60)
theta_B = M*2*math.pi/60

theta = abs(theta_A - theta_B)
if theta > math.pi:
    theta = 2*math.pi - theta

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

Solution (Python):
import math

def main():
    A, B, H, M = map(int, input().split())
    h_theta = 2*math.pi * H / 12 + (2*math.pi / 12) * M /60
    m_theta  = 2*math.pi * M / 60
    theta_diff = h_theta - m_theta
    diff = (A**2+B**2-2*A*B*math.cos(theta_diff))**0.5
    print(diff)

    
if __name__ == '__main__':
    main()

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

mdo=m*math.pi/30.0
min=[b*math.sin(mdo),b*math.cos(mdo)]
hdo=h*math.pi/6.0+m*math.pi/360.0
hour=[a*math.sin(hdo),a*math.cos(hdo)]

ans=math.sqrt(pow(abs(min[0]-hour[0]),2)+pow(abs(min[1]-hour[1]),2))

print(ans)

Solution (Python):
import math

a,b,h,m=map(int,input().split())
m=h*60+m
aa=(0.5*m)%360
ba=(6*m)%360
ang=abs(aa-ba)
cos=math.cos(math.radians(ang))

ll=a*a+b*b-2*a*b*cos
ans=ll**0.5
print(ans)

Solution (Python):
import math

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

deg_H = 30 * H + 0.5 * M
deg_M = 6 * M
deg = abs(deg_H - deg_M) if abs(deg_H - deg_M) <= 180 else 360 - abs(deg_H - deg_M)

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

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



sys.setrecursionlimit(10**7)






A, B, H, M = map(int,input().split())
ji = 30*H+M/2
hun = 6*M
ans = 0

if(ji==hun):
    print(abs(A-B))
elif(ji<hun):
    kaku = hun-ji
    sink = A*math.sin(math.radians(kaku))
    cosk = A*math.cos(math.radians(kaku))
    ans = math.sqrt((B-cosk)**2+sink**2)
    print(ans)
else:
    kaku = hun-ji
    sink = B*math.sin(math.radians(kaku))
    cosk = B*math.cos(math.radians(kaku))
    ans = math.sqrt((A-cosk)**2+sink**2)
    print(ans)

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

l_ = M * 6
s_ = (H*60+M) * 360 / (12*60)
k_ = abs(s_ - l_)

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

Solution (Python):
import numpy as np
a,b,h,m = map(int,input().split())
time = h*60 + m
angle_a = 360*time/(12*60)
angle_b = 360*m/60
tmp = np.abs(angle_a - angle_b)
if tmp > 180:
    tmp = 360 - tmp
print(np.sqrt(a**2 + b**2 - 2*a*b*np.cos(tmp*np.pi/180)))

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

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


L = 30 * A[2] + 0.5 * A[3]
S = 6 * A[3]

x = A[0]*A[0] + A[1]*A[1] - 2*A[0]*A[1]*math.cos(math.radians(min(math.fabs(L-S)%360,360-math.fabs(L-S)%360)))
print(math.sqrt(x))

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

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

from math import sin,cos,pi,sqrt

hh=2*pi*(h+m/60)/12
mm=2*pi*m/60
rad=hh-mm
l=sqrt(a**2+b**2-2*a*b*cos(rad))

print(l)

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



pai = 3.141592653589
kaku = abs((360 * m / 60) - (30 * h + m * 30 /60))

cc = a*a + b*b - 2*a*b* math.cos(math.radians(kaku)) 



print(cc**0.5)

Solution (Python):
import math


raw_input = list(map(int, input().strip().split()))
h_len = raw_input[0]
m_len = raw_input[1]
h = raw_input[2] / 12
m = raw_input[3] / 60
m_degree = 360 * m
h_degree = 360 * h + 30 * m
abs_degree = abs(m_degree - h_degree)
a_len = h_len ** 2 + m_len ** 2 - 2 * h_len * m_len * math.cos(math.radians(abs_degree))
print(math.sqrt(a_len))

Solution (Python):
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache

sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


a, b, h, m = inpl()
h_rad = (h * 60 + m) / 720 * 2 * math.pi
m_rad = 2 * math.pi * m / 60
print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(abs(h_rad - m_rad))))

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

h = H % 12
m = M % 60

rh = (h/12+M/60*1/12)*2*math.pi
rm = (m/60)*2*math.pi
r = min(rh - rm, 2*math.pi - (rh - rm))

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
n = 6 * m
t = 30 * h + 0.5 * m
d = abs(n - t)
if d > 360 - d:
    d = 360 -d
cc = a * a + b * b - 2 * a * b * (math.cos(math.radians(d)))
print(math.sqrt(cc))

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

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

Solution (Python):


import sys
import math
import itertools

debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (a, b, h, m) = [int(e) for e in lines[0].split(' ')]
        
    return (a, b, h, m)


def solve(a, b, h, m):


    m_angle = m * 360 / 60
    h_angle = h * 360 / 12 + 30 * m_angle / 360
    
    
    a_b_angle = min([abs(h_angle - m_angle), 360 - abs(h_angle - m_angle)])

    cc = a**2 + b**2 - 2 * a * b * math.cos(2 * math.pi * a_b_angle / 360)
    
    result = math.sqrt(cc)

    return  result


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Solution (Python):
import numpy as np
a, b, h, m = map(int, input().split())
t = abs(6 * m - 30 * (h + m / 60))
t = min(360 - t, t)
t = np.deg2rad(t)
c = (a**2 + b**2 - 2 * a * b * np.cos(t))**0.5
print(c)

Solution (Python):
import sys
import math

A, B, H, M = [int(i) for i in input().split()]
thetaA = (H + M / 60) * (math.pi / 6)
thetaB = 2 * math.pi * (M / 60)
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(thetaB - thetaA)))

Solution (Python):
import math
ABHM = list(map(int, input().split()))

radHM = math.pi * 2
mCorrection = ABHM[3] / 60
if ((ABHM[2] + mCorrection) * 5 > ABHM[3]):
    radHM *= ((ABHM[2] + mCorrection) * 5 - ABHM[3]) / 60
else:
    radHM *= (ABHM[3] - (ABHM[2] + mCorrection) * 5) / 60

print(math.sqrt(ABHM[0] * ABHM[0] + ABHM[1] * ABHM[1] - 2 * ABHM[0] * ABHM[1] * math.cos(radHM)))

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


Mangle = 6*M

Hangle = 30*H + 0.5*M

angle = abs(Mangle - Hangle)

angle = min(angle, 360-angle)

angle = math.radians(angle)


answer = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))
print(answer)

Solution (Python):
import math
x = input()
xs = x.split(" ")
A = int(xs[0])
B = int(xs[1])
H = int(xs[2])
M = int(xs[3])

Hangle = M/2 + H*30
Mangle = M*6



if (Hangle > Mangle):
    angleBetween = Hangle - Mangle
else:
    angleBetween = Mangle - Hangle



if (360 - angleBetween) < angleBetween:
    angleBetween = 360 - angleBetween

angleBetween = angleBetween * math.pi
angleBetween = angleBetween/180

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

Solution (Python):
import sys
import math


a,b,h,m=map(int,input().split())
mi=6*m
ho=30*h+(1/12)*mi

ang=min(abs(mi-ho),360-abs(mi-ho))

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

Solution (Python):
import math

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

theta_H = (2 * math.pi * H / 12) + 2 * math.pi *M / 60 / 12
theta_M = 2 * math.pi * M / 60

C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(abs(theta_H-theta_M)))

print(C)

Solution (Python):
import math

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

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

deg=deg if deg<=math.pi else (2*math.pi-deg)

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

if deg==0:
    print(abs(A-B))
elif deg==math.pi:
    print(abs(A+B))
else:
    print(l)

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


a_kakudo = 90-(30*h + (1/2) * m)
b_kakudo = 90- 6 *m


x = math.sqrt((a*math.cos(math.radians(a_kakudo)) - b*math.cos(math.radians(b_kakudo)))**2 + (a*math.sin(math.radians(a_kakudo)) - b*math.sin(math.radians(b_kakudo)))**2)
print(x)

Solution (Python):


import math
a, b, h, m = map(int, input().split())
x = abs(30 * h + m / 2 - 6 * m)
if x <= 180:
    d = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(x)))
else:
    x = 360 - x
    d = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(x)))
print(d)

Solution (Python):
import math


aLength, bLength, hour, minite = map(int, input().split())


aRadian = 2 * math.pi * (hour + minite/60) / 12
bRadian = 2 * math.pi * minite / 60


aPosX, aPosY = (aLength*math.cos(aRadian), aLength*math.sin(aRadian))
bPosX, bPosY = (bLength*math.cos(bRadian), bLength*math.sin(bRadian))


print(math.sqrt((aPosX-bPosX)**2 + (aPosY-bPosY)**2))

Solution (Python):
from decimal import *
setcontext(Context(prec=200,rounding=ROUND_UP))
factorial=[1]
fac=Decimal('1')
for i in range(2,150):
    fac*=Decimal(i)
    factorial.append(fac)

def cos(s):
    cos=Decimal('1')
    s=Decimal(s)
    for i in range(4,100,4):
        cos+=(Decimal((s**Decimal(i)))/Decimal(factorial[i-1]))
    for i in range(2,100,4):
        cos-=(Decimal((s**Decimal(i)))/Decimal(factorial[i-1]))
    return cos

def radian_convert(s):
    s=Decimal(s)
    return s*Decimal('3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066')/Decimal('180')

a,b,c,d=input().split()
a=Decimal(a)
b=Decimal(b)
c=Decimal(c)
d=Decimal(d)
angle=(d/Decimal('60')*Decimal('360')-c/Decimal('12')*Decimal('360')-d/Decimal('60')*Decimal('30'))
ans=Decimal.sqrt(a*a+b*b-2*a*b*cos(radian_convert(angle)))
print(ans)

Solution (Python):
import math
PI = 3.14159265358979
a,b,h,m = map(int, input().split())
sh = 30 * h + m * 0.5
lo = 6 * m
rad = abs(sh - lo) * PI / 180
r = (a * a + b * b - 2 * a * b * math.cos(rad)) ** .5
print(r)

Solution (Python):
import math

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

As = 2 * math.pi * (H + M/60)/12
Bs = 2 * math.pi * M / 60

S = abs(As-Bs)
C = math.sqrt(A**2+B**2-2*A*B*math.cos(S))

print(C)

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

import math

alpha = math.radians(0.5*(60*H + M))
beta = math.radians(6*M)

c2 = A*A + B*B - 2*A*B* math.cos(beta - alpha)

c = math.sqrt(c2)
print(c)

Solution (Python):
import math

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

hour_rad = (H*60+M)*2.0/(12*60)
min_rad = M*2/60.0

diff_rad = max(hour_rad,min_rad) - min(hour_rad,min_rad)
if diff_rad > 1:
	diff_rad = 2 - diff_rad
dist_sq = A**2 + B**2 - 2*A*B*math.cos(diff_rad*math.pi)

print math.sqrt(dist_sq)

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

deg = abs(360/12*H + 360/12/60*M - 360/60*M)
c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(deg/180*math.pi))
print(c)

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

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

m1 = Decimal(6)
h1 = Decimal(1) / Decimal(2)
m2 = Decimal(m1) * Decimal(m)
h2 = Decimal(h) * Decimal(30) + Decimal(h1) * Decimal(m)

ans = Decimal(a ** 2 + b ** 2 - 2 * a * b *
              math.cos(math.radians(abs(h2 - m2)))) ** (Decimal(1) / Decimal(2))
print('{: .10f}'.format(ans))

Solution (Python):
import sys
import math

input = sys.stdin.readline

def main():
    ans = 0
    A, B, H, M = map(int, input().split())
    h = 0.5*(H*60+M)
    m = 6*M
    d = abs(h-m)
    r = math.radians(d)
    ans = A**2 + B**2 - 2*A*B*math.cos(r)

    print('{:.20}'.format(ans**0.5))

if __name__ == '__main__':
    main()

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

x = h * 30
tmp = max(6 * m, x + m * 0.5) - min(6 * m, x + m * 0.5)
if tmp > 180:
    tmp = 360 - tmp
print((a ** 2 + b ** 2 - 2 * a * b * math.cos(tmp * (math.pi / 180))) ** 0.5)

Solution (Python):
import math
a,b,h,m = map(int, input().split())
 
hrad = 30 * h + 0.5 * m
mrad = 6 * m
diff = abs(hrad - mrad)
if diff > 180:
  diff = abs(mrad - hrad)
  
ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(diff)))
print(ans)

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

rad = math.cos((m/30-(h+m/60)/6)*math.pi)

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

Solution (Python):
import numpy as np
a, b, h, m = map(int, input().split())
h_deg = (h*60+m)/720
m_deg = m/60
deg = max(h_deg-m_deg, m_deg-h_deg)
deg = 1.0-deg if deg > 0.5 else deg
if deg == 0.5:
    print('{:.20f}'.format(a+b))
else:
    print('{:.20f}'.format(np.sqrt(a**2+b**2-(2*a*b*np.cos(2*np.pi*deg)))))

Solution (Python):


from math import pi, cos, sin

iim = lambda: map(int, input().rstrip().split())

def resolve():
    A, B, H, M = iim()

    ar =  2 * pi * (H / 12 + M / (12 * 60))
    br =  2 * pi * M / 60

    ai = A * complex(cos(ar), sin(ar))
    bi = B * complex(cos(br), sin(br))


    print(abs(ai - bi))

if __name__ == "__main__":
    resolve()

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

Solution (Python):
import math, numpy
a, b, h, m = map(int,input().split())
x1 = a * math.sin(math.radians((h * 360 / 12) + (m / 2)))
y1 = a * math.cos(math.radians((h * 360 / 12) + (m / 2)))
x2 = b * math.sin(math.radians(m * 6))
y2 = b * math.cos(math.radians(m * 6))
hh = numpy.array([x1, y1])
mm = numpy.array([x2, y2])
u = mm - hh
print(numpy.linalg.norm(u))

Solution (Python):
import math

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

shortHandAngle = math.radians(30*H+float(M/2))
longHandAngle = math.radians(6*M)

x = A * math.cos(shortHandAngle)\
    - B * math.cos(longHandAngle)

y = A * math.sin(shortHandAngle)\
    - B * math.sin(longHandAngle)

d = math.sqrt(x**2 + y**2)

print(d)

Solution (Python):
import math

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

a = H * 30 + M / 2
b = M * 6
c = abs(a-b)

if c > 180:
    c = 360 - c

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
theta_long = 6 * m
theta_short = 30 * h + m / 2
theta = theta_short - theta_long
theta = min(theta, (360 - theta))
s = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(theta)))
print(s)

Solution (Python):
import math

A,B,H,M=map(int,input().split())
cosM=math.cos(math.radians(30*H-11*M/2))
D=math.sqrt(A**2+B**2-2*A*B*cosM)
print(D)

Solution (Python):
import math
A, B, N, M = map(int, input().split())
a = (N * 60 + M) / 2
b = M * 6
c = abs(a - b)
c = math.radians(min(c, 360 - c))
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())

thetaA =  math.radians(0.5*(60*H+M))
thetaB = math.radians(6*M)

Ax = A*math.cos(thetaA)
Ay = A*math.sin(thetaA)

Bx = B*math.cos(thetaB)
By = B*math.sin(thetaB)

dis = math.sqrt(pow(Ax-Bx,2) + pow(Ay-By,2))
print(dis)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
l_rad = m / 60 * 360
s_rad = h * 30 + m / 60 * 30
c_rad = abs(l_rad - s_rad) if abs(l_rad - s_rad) <= 180 else 360 - abs(l_rad - s_rad)
cos_c = math.cos(math.radians(c_rad))
if cos_c == 1:
    print(abs(a - b))
elif cos_c == -1:
    print(a + b)
else:
    print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos_c))

Solution (Python):
import math

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

h_x=a*math.cos(math.pi*2*(h+m/60)/12)
h_y=a*math.sin(math.pi*2*(h+m/60)/12)
m_x=b*math.cos(math.pi*2*m/60)
m_y=b*math.sin(math.pi*2*m/60)

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

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

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

minutes = H * 60 + M

choshin = (minutes * 6) % 360
tanshin = (minutes * 0.5) % 360

if choshin == tanshin:
    print(abs(B - A))
else:
    C = abs(choshin - tanshin)
    tmp = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(math.radians(C)))
    print(math.sqrt(tmp))