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):
from sys import stdin
import sys
import math


A, B, H, M = [int(x) for x in stdin.readline().rstrip().split()]
h = 30*H+M/60*30
m = 6*M
temp = abs(h-m)
if 360-temp < temp:
    temp = 360-temp
ans = A*A+B*B-2*A*B*math.cos(math.radians(temp))
print(math.sqrt(ans))

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

minute = H*60+M
h_n = (6*minute)%360
m_n = (0.5*minute)%360


if h_n > m_n:
    r = h_n - m_n
    Cos = math.cos(math.radians(r))
    a = math.sqrt(A**2 + B**2 - 2*A*B*Cos)
else:
    r = m_n - h_n
    Cos = math.cos(math.radians(r))
    a = math.sqrt(A**2 + B**2 - 2*A*B*Cos)

print(a)

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

print(ans)

Solution (Python):
import math

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

hour = 30 * (M / 60) + 360 * (H / 12)
minute = 360 * (M / 60)

if hour > minute:
    degree = hour - minute
else:
    degree = minute - hour

degree = 360 - degree if degree > 180 else degree
length = A**2 + B**2 - 2 * A * B * math.cos(math.radians(degree))
print(math.sqrt(length))

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

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

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

Solution (Python):
import math

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

A_deg = 30.0 * H + 0.5 * M
B_deg = 6.0 * M

print(math.sqrt(A ** 2 + B ** 2 - 2.0 * A * B *  math.cos(math.radians(A_deg-B_deg))))

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

if alpha>beta:
    sita=alpha-beta
else:
    sita=beta-alpha

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

c=(a**2+b**2-2*a*b*math.cos(sita))**(1/2)
print(c)

Solution (Python):
import math

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

wA = 360 / (12*60)
wB = 360 / 60

theta_A = (60*H+M) * wA
theta_B = M * wB

theta = abs(theta_A - theta_B)
output = math.sqrt(abs(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta))))
print(output)

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

x=6*M
y=30*H+(M/60)*30
Q=max(x-y,-(x-y))
W=min(360-Q,Q)

X=(A**2)+(B**2)-2*A*B*(math.cos(math.radians(W)))
print(X**(0.5))

Solution (Python):
import math
A,B,H,M=map(int,input().split())
h=30*H+M/2
m=6*M
y=abs(h-m)
x_2=A*A+B*B-2*A*B*(math.cos(math.radians(y)))
x=x_2**(0.5)
print(x)

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

ans = 0
t = 60 * H + M 
h_a = 0.5
m_a = 6
angle = (5.5 * t) % 360

if angle > 180:
    angle = 360 - angle
    ans = A ** 2 + B ** 2 - 2 * A * B * np.cos(np.radians(angle))
    print(np.sqrt(ans))
else:
    ans = A ** 2 + B ** 2 - 2 * A * B * np.cos(np.radians(angle))
    print(np.sqrt(ans))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
m_ang = 360 * m / 60
h_ang=360*h/12+30*m/60
angle = abs(m_ang-h_ang)
if angle > 180:
    angle = 360 - angle



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

print(d)

Solution (Python):
import math
A,B,H,M=map(int,input().split())
hour = (H/6+M/360)*math.pi
minute = M/30*math.pi
radi = abs(hour-minute)

if radi > math.pi:
  ans = math.sqrt(A**2+B**2-2*A*B*math.cos(2*math.pi-radi))
else:
  ans = math.sqrt(A**2+B**2-2*A*B*math.cos(radi))
print(ans)

Solution (Python):

import math

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

Mdegrees = 360 * (float(M)/60.0)
if H >= 12:
  H -= 12
trueH = H + (float(M)/60.0)
Hdegrees = 360 * (trueH/12.0)

degrees = 0
if Mdegrees <= Hdegrees:
  degrees = Hdegrees - Mdegrees
else:
  degrees = Mdegrees - Hdegrees

radians = math.radians(degrees)
b = math.sqrt(A*A + B*B - 2*A*B*math.cos(radians))
print(b)

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

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

import math

ji = (30 * H) + (0.5 * M)
hu = 6 * M
ka = ji- hu

if ka == 0:
    print(abs(B-A))
elif abs(ka) == 180:
    print(A+B)
elif ka > 0:
    co = math.cos(math.radians(ka))
    ans = A**2 + B**2 - 2*A*B*co
    print(ans**(0.5))
elif ka < 0:
    ka *= -1
    co = math.cos(math.radians(ka))
    ans = A**2 + B**2 - 2*A*B*co
    print(ans**(0.5))

Solution (Python):
import numpy as np
[A,B,H,M] =list(map(int,input().split()))
t = H*60+M
oma = np.pi/360. 
omb = np.pi/30. 
tha  = oma * t
thb  = omb * t
tha, thb = tha%(2*np.pi),thb%(2*np.pi)


L = A**2 + B**2 - 2*A*B*np.cos(tha-thb)
L = np.sqrt(L)
print(L)

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

M_theta = 2.0 * np.pi * M / 60.0
H_theta = 2 * np.pi * ( H / 12.0  + (M / 60.0) / 12.0 ) 
print( (A**2 + B**2 - 2 * A * B * np.cos(M_theta - H_theta))**0.5 )

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

from math import pi, cos, sin, sqrt, degrees

dh = 2 * pi / 12
dm = 2 * pi / 60

def solve(a, b, h, m):
    long_theta = dm * m
    short_theta = dh * h + dm/12 * m
    ly, lx = b * cos(long_theta), b * sin(long_theta)
    sy, sx = a * cos(short_theta), a * sin(short_theta)
    return sqrt((lx - sx)**2 + (ly - sy)**2)


def main():
    a, b, h, m = input_from_console()
    print(solve(a, b, h, m))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  
        check_cases()
    else:
        main()

Solution (Python):
import math

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

x = 30*h + 0.5*m - 6*m
x = min(x, 360-x)

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

Solution (Python):
from sys import stdin
from math import cos, sin, pi, sqrt, radians, degrees
from collections import deque, Counter, defaultdict
import heapq

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    A, B, H, M = map(int, input().split())
    th1 = pi / 2 - H / 12 * 2 * pi
    if th1 < 0:
        th1 += 2 * pi

    if M != 0:
        th1 -= 2 * pi / 12 * (M / 60)
    Ax = A * cos(th1)
    Ay = A * sin(th1)
    th2 = pi / 2 - M / 60 * 2 * pi
    if th2 < 0:
        th2 += 2 * pi
    Bx = B * cos(th2)
    By = B * sin(th2)
    d = sqrt((Ax - Bx) ** 2 + (Ay - By) ** 2)
    print("{:.10f}".format(d))

if __name__ == '__main__':
    main()

Solution (Python):
abhm=tuple(map(float, input().split()))
a=abhm[0]
b=abhm[1]
h=abhm[2]
m=abhm[3]

import math as mt

pi=mt.pi

c=pi*(h+m/60)/6
d=pi*m/30

print(mt.sqrt((a*mt.cos(c)-b*mt.cos(d))**2+(a*mt.sin(c)-b*mt.sin(d))**2))

Solution (Python):
import numpy as np

PI = 3.141592
P = 3.141592653589793238462643383279502884197169399
A, B, H, M = map(int, input().split())

A_ang = (30*H) + (0.5*M)
B_ang = 6 * M

angle = abs(A_ang - B_ang)
if angle > 180:
    angle = 360-angle

angle = (angle/360) * 2*P

a = (A*A) + (B*B) - (2*A*B*np.cos(angle))

a = np.sqrt(a)
print(a)

Solution (Python):
import math
PI=3.14159265358979323846
a,b,h,m = map(float, input().split())
i=(h+m/60.0)*PI/6.0;
j=m*PI/30.0;
if i>j and i-j>PI:
    n=2*PI-(i-j)
elif i>j and i-j<=PI:
    n=i-j
elif j>=i and j-i>PI:
    n=2*PI-(j-i)
elif j>=i and j-i<=PI:
    n=j-i
x=math.sqrt(a*a+b*b-2*a*b*math.cos(n))
print(x)

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

minutes = h * 60 + m

h_radian = math.radians(minutes / 60 * 30)
m_radian = math.radians(minutes * 6)








h_x = a * math.sin(h_radian)
h_y = a * math.cos(h_radian)
m_x = b * math.sin(m_radian)
m_y = b * math.cos(m_radian)

i = numpy.array([h_x, h_y])
j = numpy.array([m_x, m_y])

print(numpy.linalg.norm(i - j))

Solution (Python):
A,B,H,M=map(int,input().split())
import numpy as np
X=(H/12+M/(12*60)-M/60)*2*np.pi
if X<=np.pi:
  Y=X
else:
  Y=2*np.pi-X
print(np.sqrt((A-B*np.cos(Y))**2+(B*np.sin(Y))**2))

Solution (Python):
import numpy as np

A, B, H, M = map(int, input().split())
H_kakudo = (H * 60 + M) / (12 * 60) * np.pi * 2
M_kakudo = M / 60 * 2 * np.pi
HM_kakudo = abs(H_kakudo - M_kakudo)
ans = A**2 + B**2 - 2*(A*B*np.cos(HM_kakudo))
print(np.sqrt(ans))

Solution (Python):
import numpy as np
import math

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

m_co = m * 6

h_co = h * 30 + m * 0.5

t = np.abs(h_co - m_co)

cor = min(t, 360-t)

ans = float(((a ** 2) + (b ** 2) - 2 * a * b * math.cos(math.radians(cor))) ** 0.5)

print(ans)

Solution (Python):
import math


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

    ht = (h/12 + m/720) * 2 * math.pi
    mt = (m/60) * 2 * math.pi
    theta = min(abs(ht - mt), 2 * math.pi - abs(ht - mt))

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


if __name__ == '__main__':
    main()

Solution (Python):
import math as ma

a,b,h,m = map(int,input().split())
degA,degB = h*30 + m*0.5, m*6
rad = ma.radians(abs(degA - degB))

ans = (a**2 + b**2 - 2*a*b*ma.cos(rad)) **0.5
print(ans)

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

jikan=h*60+m
bdeg=6*jikan
adeg=0.5*jikan
theta=(bdeg-adeg)/180.*math.pi

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

print (nagasa)

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

x = min(abs(h1-m1),360-(abs(h1-m1)))

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

Solution (Python):
import math
A, B, H, M = map(int, input().split())
l = 6.0 * M
s = (30.0 * H) + (0.5 * M)
arg = abs(l - s)
cos = math.cos(math.radians(arg))
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())
tha, thb = math.pi / 6 * (h + m / 60), m / 30 * math.pi
print((a**2 + b**2 - 2*a*b*math.cos(max(tha, thb) - min(tha, thb)))**0.5)

Solution (Python):
a,b,h,m = map(int,input().split())
import math
t =abs(30*h + 0.5*m - 6*m)
angle = min(t, 360-t)

l = a**2 + b** 2 -2*a*b*math.cos(angle*3.14159265358979323846/180)
print(l**0.5)

Solution (Python):
import math

[a, b, h, m] = [int(s) for s in input().split()]
hd = h * 30 + m * 0.5
md = m * 6
d = abs(hd - md)
if d > 180:
    d = 360 - d

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

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

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

a_x = A*(math.sin(math.radians(H*30+M/2)))
a_y = A*(math.cos(math.radians(H*30+M/2)))
b_x = B*(math.sin(math.radians(M*6)))
b_y = B*(math.cos(math.radians(M*6)))

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

print(l)

Solution (Python):
import math

a,b,h,w = map(int, input().split())
if w == 0:
    c = abs(h*30-360)
else:
    c = min(abs(h*30-w*5.5), abs(w*5.5-h*30))

cosc = math.cos(math.radians(c))

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

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

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

def main():
    A, B, H, M = map(int, input().split())
    small = 360 * (M / 60)
    big = 360 * (H/12) + 30 * (M/60)
    deg = small - big
    rad = radians(deg)
    d2 = A**2.0 + B**2.0 - 2*A*B*cos(rad)
    print(sqrt(d2))
    
if __name__ == "__main__":
    main()

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

Solution (Python):
import math
a,b,h,m= map(int, input().split())
pi=math.pi
mi=60*h+m
hpi=2*pi*mi/(12*60)
mpi=2*pi*m/60
a1=a*math.sin(hpi)
a2=a*math.cos(hpi)
b1=b*math.sin(mpi)
b2=b*math.cos(mpi)
cc=math.sqrt((a1-b1)**2+(a2-b2)**2)
print(cc)

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

cosC = math.cos(math.radians(abs((30*H+0.5*M)-6*M)))

C = (A**2 + B**2 - 2*A*B*cosC)**0.5

print(C)

Solution (Python):
import sys
import math

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
A,B,H,M=LI()

ta = -(float(H+(M/60))*math.pi/6.0) + (math.pi*0.5)
tb = -(float(M)*math.pi/30.0) + (math.pi*0.5)
Ax = A*math.cos(ta)
Ay = A*math.sin(ta)

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

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

Solution (Python):
import math

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


xh = a * math.sin(h*P/6 + m*P/360)
yh = -a * math.cos(h*P/6 + m*P/360)


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

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

Solution (Python):
import math as mt

value = input().split(' ')
short = int(value[0])
long = int(value[1])
hour = int(value[2])
minute = int(value[3])

anglong = 6 * minute
angshort = 30 * (hour + minute/60)


radialang = anglong - angshort
if(radialang >= 180):
  radialang = -1 * radialang
  
rad = radialang * mt.pi / 180

ans = mt.sqrt(long**2 + short**2 - 2*long*short*mt.cos(rad))

print(ans)

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

ang_h = H * 30 + M * 0.5
ang_m = M * 6
ang = min(abs(ang_h - ang_m), 360 - abs(ang_h - ang_m))
c = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(ang)))
print(c)

Solution (Python):
from math import sin, cos, pi, sqrt
a, b, h, m = map(float, input().split())
A = [a * cos(2 * pi * (h * 60 + m) / 720), a * sin(2 * pi * (h * 60 + m) / 720)]
B = [b * cos(2 * pi * m / 60), b * sin(2 * pi * m / 60)]
print("{:.15f}".format(sqrt((A[0] - B[0])**2 + (A[1] - B[1])**2)))

Solution (Python):
from math import cos,pi

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

deg = abs((h*60 + m)/2.0 - m*6)
deg = min(deg, 360-deg)
print((a**2+b**2-2*a*b*cos(deg/180 * pi))**0.5)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
L_rad = (H + M / 60) * math.pi / 6
S_rad = M / 30 * math.pi
LS_d = max(L_rad, S_rad) - min(L_rad, S_rad)
if LS_d > math.pi:
    LS_d = 2 * math.pi - LS_d
print(math.sqrt(A**2+B**2-2*A*B*math.cos(LS_d)))

Solution (Python):
import math

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

alpha = 1 / 6 * h * math.pi + 1 / 360 * m * math.pi
beta = m * math.pi / 30

x_a = a * math.sin(alpha)
y_a = a * math.cos(alpha)
x_b = b * math.sin(beta)
y_b = b * math.cos(beta)

ans = math.sqrt((x_a - x_b) ** 2 + (y_a - y_b) ** 2)

print(ans)

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

rad2=360*(M/60)
rad1=((H*30+M*0.5))
if (180<=abs(rad1-rad2)):
    C=(A**2)+(B**2)-(2*A*B*math.cos(math.radians(360-abs(rad1-rad2))))
else:
    C=(A**2)+(B**2)-(2*A*B*math.cos(math.radians(abs(rad1-rad2))))
print(math.sqrt(C))

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

Solution (Python):
import math

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

alpha=(60*H+M)/2
beta=6*M

cos=math.cos(math.radians(beta-alpha))

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

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

def main():
  A, B, H, M = map(int, readline().split())
  ax = A * math.cos(2 * math.pi * (H + M / 60) / 12)
  ay = A * math.sin(2 * math.pi * (H + M / 60) / 12)
  bx = B * math.cos(2 * math.pi * M / 60)
  by = B * math.sin(2 * math.pi * M / 60)
  l = math.sqrt((ax-bx)**2 + (ay - by)**2)
  print(l)

if __name__ == '__main__':
  main()

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

mka = m*6
hka = h*30+ 30*(m/60)
kaku = abs(mka-hka)
kaku = min(kaku, 360-kaku)

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

Solution (Python):
import math
A,B,C,D = map(int,input().split())
A_rad = math.radians(C*30 + 0.5*D)
B_rad = math.radians(D*6)

A_x,A_y = A*math.sin(A_rad),A*math.cos(A_rad)
B_x,B_y = B*math.sin(B_rad),B*math.cos(B_rad)

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

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

a_theta = (h / 12.0) * 360 + (m / 60.0) * 30
a_x = a * math.sin((2*math.pi)*((a_theta)/360.0))
a_y = a * math.cos((2*math.pi)*((a_theta)/360.0))

b_theta = (m / 60.0) * 360
b_x = b * math.sin((2*math.pi)*((b_theta)/360.0))
b_y = b * math.cos((2*math.pi)*((b_theta)/360.0))

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

Solution (Python):
A, B, H, M = map(int, input().split())
import math
kakudoA = 30 * H + 30 * (M / 60)
kakudoB = 6 * M
sa = min(abs(kakudoA - kakudoB), 360 - abs(kakudoA - kakudoB))
co = math.cos(math.radians(sa))
C = (A ** 2 + B ** 2 - 2 * A * B * co) ** (1/2)
print(C)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
ba = (360 / 60) * m
aa = 30*h +(30/60)*m
ca = aa - ba
if ca >= 180:
    ca1 = 360-ca
else:
    ca1 = ca

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

Solution (Python):
import math

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




chou=6*M
tan=(H*60+M)*360/(12*60)

d=abs(chou-tan)
if d>180:
    d=360-d
ra=math.radians(d)
co=math.cos(ra)
a=A**2 + B**2 - 2*A*B*co

a=math.sqrt(a)
print(a)

Solution (Python):
import math

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


dH = 360 / 720 
dM = 360 / 60 

delta = 60 * H + M 

theta = delta * dH - M * dM

if theta < 0:
    theta = M * dM - delta * dH
if 180 < theta:
    theta = 360 - theta

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

print(C)

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

minute = 60*H + M
thetaA = 2*math.pi * minute/(60*12)
thetaB = 2*math.pi * M/60
d = math.sqrt(A**2+B**2 - 2*A*B*math.cos(abs(thetaA-thetaB)))
print(d)

Solution (Python):


import math

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

ht = 360 * h / 12 + 360 * m / 60 / 12
mt = 360 * m / 60

t = abs(ht - mt) if abs(ht - mt) <= 180 else 360 - abs(ht - mt)

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

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

Solution (Python):
import math

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


MM = M*6

HH = ((H*30) + (M/2))



rad = abs(MM-HH)

if rad >= 181:
    rad = 360 - rad

rad = math.radians(rad)

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

m_ang = m*math.pi/30
h_ang = (h*30+m/2)*math.pi/180
ang = m_ang - h_ang
c = math.sqrt(a*a+b*b-2*a*b*math.cos(ang))

print(c)

Solution (Python):
import math

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

hr = (h * 60 + m ) / 2
mr = m * 6
if mr == 0:
    mr = 360

if mr > hr:
    r = mr - hr
else:
    r = hr - mr

c = math.cos(math.radians(r))
s = a ** 2 + b ** 2 - 2 * a * b * c
s = math.sqrt(s)

print(s)

Solution (Python):
import sys
import math
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

ang_H = (360 / 12 * H) + (360 / 12 / 60 * M)
ang_M = (360 / 60 * M)

ang_between = max(ang_H, ang_M) - min(ang_H, ang_M)
cos = math.cos(math.radians(ang_between))
L = np.sqrt(pow(A, 2) + pow(B, 2) - (2 * A * B * cos))

print(L)

Solution (Python):
import numpy as np
A,B,H,M = map(int,input().split())
degree = abs(30*H+(1/2)*M-6*M)
L = np.sqrt(A**2+B**2-2*A*B*(np.cos(np.radians(degree))))
print(L)

Solution (Python):
import math as m

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

angle = abs((H * 60 + M) * 0.5 - M * 6)

ans = (A ** 2 + B ** 2 - 2 * A * B * m.cos(m.radians(angle))) ** 0.5
print(ans)

Solution (Python):
import numpy as np
def main():
    A, B, H, M = map(int, input().split())
    omega_m = 1.0/60.0
    omega_h = 1.0/12.0
    a = (H + M/60.0) * omega_h
    b = (60.0*H + M) * omega_m
    theta = (a - b) * 360.0
    c = np.sqrt(A**2 + B**2 - 2.0*A*B*np.cos(theta/180.0*np.pi))
    print(c)
if __name__ == '__main__':
    main()

Solution (Python):
import math

a, b, h, m = [0] * 4

def format_input(filename = None):
	global a, b, h, m
	if filename == None:
		a, b, h, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		a = rng(1, 10**3)
		b = rng(1, 10**3)
		h = rng(0, 11)
		m = rng(0, 59)
		print(a, b, h, m)

def get_answer():
	answer = 0
	rad = 2.0 * math.pi * abs(float(h) / 12.0 + float(m) / 60.0 / 12.0 - float(m) / 60.0)
	answer = math.sqrt((float(a) * math.sin(rad))**2 + (float(a) * math.cos(rad) - float(b))**2)
	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans)

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

C()

Solution (Python):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
import math

a,b,h,m=LI()

def yogen(x,y,z):
    t=x*x+y*y-2*x*y*math.cos(z)
    return t**.5
    
kakudo=math.radians((30*(h+m/60)-6*m))


print(yogen(a,b,kakudo))

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

import math
si = math.radians(30*h -5.5*m)
c = (a**2+b**2-2*a*b*math.cos(si))**0.5
print(c)

Solution (Python):
import numpy as np

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

minute = h*60 + m
a_ang = (minute%720 * np.pi) / 360
b_ang = (minute%60 * np.pi) / 30

theta = min(abs(a_ang-b_ang), abs(b_ang-a_ang))

c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(theta))
print("{:.12f}".format(c))

Solution (Python):
import math

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

kakudo_min=M/60*360
kakudo_hour=H/12*360+M/720*360
kakudo=0

if abs(kakudo_min-kakudo_hour)<180:
	kakudo=abs(kakudo_min-kakudo_hour)
	cosAB=math.cos(math.radians(kakudo))
	print((A**2+B**2-2*A*B*cosAB)**0.5)
	
elif abs(kakudo_min-kakudo_hour)>180:
	kakudo=360-abs(kakudo_min-kakudo_hour)
	cosAB=math.cos(math.radians(kakudo))
	print((A**2+B**2-2*A*B*cosAB)**0.5)
	
else:
	print(A+B)

Solution (Python):
import math
import numpy as np

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

    
    time = H * 60 + M

    
    
    argmin = time * math.pi / 30
    arghour = time * math.pi / 360

    xh = A * math.cos(arghour)
    yh = A * math.sin(arghour)
    h = np.array([xh, yh])

    xm = B * math.cos(argmin)
    ym = B * math.sin(argmin)
    m = np.array([xm, ym])

    d = np.linalg.norm(h-m)

    print(d)

if __name__ == "__main__":
    main()

Solution (Python):
import math


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

short_time = H*0.5*60 + M*0.5
long_time = M*6
degree = abs(short_time-long_time)

x = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(degree)))

print(x)

Solution (Python):
import math

a, b, h, m = [int(_) for _ in input().split()]
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(abs(360 * (h*60+m) / 720 - 360 * m / 60)))))

Solution (Python):
import numpy as np
import math
pi = math.pi
a,b, h, m = map(int, input().split())
hkakudo = h*2*pi/12 + m*2*pi/720
mkakudo = m*2*pi/60
theta = abs(hkakudo-mkakudo)
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())
jikann = (h/12+m/720)*360
hun = (m/60)*360
kakudo = abs(jikann-hun)
if kakudo > 180:
    kakudo =  360- kakudo
kakudo = math.radians(kakudo)

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

print(ans**(1/2))

Solution (Python):

import math

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

h1 = 30*h+0.5*m

m1 = 6*m

if abs(h1-m1)>180:
    if m1>180:
        x = 360-m1+h1
    else:
        x = 360-h1+m1
else:
    x = abs(h1-m1)

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

ans2 = a*a+b*b-2*a*b*cosx

ans = ans2**(0.5)

print(ans)

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


hr = math.radians(360 * h / 12 + 30 * m /60)
mr = math.radians(360 * m / 60)

axy = (math.sin(hr)*a , math.cos(hr)*a)
bxy = (math.sin(mr)*b , math.cos(mr)*b)

print( math.sqrt((axy[0] - bxy[0])**2 + (axy[1] - bxy[1])**2) )

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

a_deg = 30*h + 0.5 * m
b_deg = 6*m
rad = math.radians(abs(a_deg - b_deg))
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))
print(c)

Solution (Python):


import math


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



theta = abs(m/60.0 - (h/12.0 + m/60.0/12.0))*2*math.pi
if theta >= math.pi:
    theta = 2*math.pi - theta




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

Solution (Python):
import math

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

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

def hour2deg(hour, min):
  return hour*30 + min/2

def min2deg(min):
  return min*6

def resolve():
  A, B, H, M = map(int, input().split(" "))
  degree = abs(hour2deg(H, M) - min2deg(M))
  if degree > 180:
    degree = 360.0 - degree
  length = sqrt(A**2 + B**2 - 2*A*B*cos(radians(degree)))
  print(length)

if __name__ == "__main__":
    resolve()

Solution (Python):
import numpy as np

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


Hd=float((H%12)*30+M*0.5) 
Md=float((M%60)*6) 
Dd=abs(Hd-Md) 
Dr=np.deg2rad(Dd) 


def calc(a,b,rad):
    return np.sqrt(a**2+b**2-2*a*b*np.cos(Dr))

print(calc(A,B,Dr))

Solution (Python):
import math

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

jishin_length = A

bunshin_length = B

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

bunshin_angle = 6 * M


tri_angle = max(jishin_angle, bunshin_angle) - min(jishin_angle, bunshin_angle)

if tri_angle >= 180:
    tri_angle = 360 - tri_angle


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

Solution (Python):
import math
A, B, H, M = map(float, input().split())
a = (H * 60 + M) / 2
b = M * 6
c = abs(a-b)
c = c if c <= 180 else 360 - c
cc = (A**2 + B**2 - 2*A*B * math.cos(math.radians(c))) ** 0.5
print(cc)

Solution (Python):
import math
A, B, H, M = map(int,input().split())
T = 60 * H + M
a = (360 /60/ 12) * T
b = ((360 / 60) * T ) % 360
k = abs(a - b)
if k > 180:
    kakudo = 360 - k
else:
    kakudo = k
X = A ** 2 + B **2 - 2 * A * B * math.cos(math.radians(kakudo)) 
print(X ** (1/2))

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

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
a_kakudo = math.degrees(math.pi)*2/12 * h
a_kakudo = a_kakudo + math.degrees(math.pi/6)/60 * m
b_kakudo = math.degrees(math.pi)*2/60 * m
mx = max(a_kakudo, b_kakudo)
mn = min(a_kakudo, b_kakudo)
cc = a*a + b*b - 2*a*b*math.cos(math.radians(mx-mn))
print(math.sqrt(cc))

Solution (Python):


import math
a, b, h, m = map(float, input().split())
long_deg = m * 6
short_deg = (h * 60 + m) * 0.5
temp_deg = abs(long_deg - short_deg)
deg = min(temp_deg, 360 - temp_deg)
temp_c = a * a + b * b - 2 * a * b * math.cos(math.radians(deg))
c = math.sqrt(temp_c)
print(c)

Solution (Python):
import numpy as np

a,b,h,m = map(int, input().split())
minutes = h*60 + m
ome1 = minutes % 60 *6
ome2 = (minutes%1800) * 0.5

rad = (ome2 - ome1) * np.pi/180
x = a**2+b**2-2*a*b*(np.cos(rad))
print(x**0.5)

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

tot_m = h * 60 + m
a_rad = 2 * pi * tot_m / 720
b_rad = 2 * pi * m / 60
dif_rad = abs(a_rad -b_rad)
if dif_rad > pi:
    theta = 2*pi - dif_rad
else:
    theta = dif_rad

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

print(c)

Solution (Python):
a,b,h,m = map(int,input().split())
import numpy as np
hkakudo = 0.5 * (60*h + m)
mkakudo = 6 * m
if abs(hkakudo-mkakudo)== 180:
    print(a+b)
elif abs(hkakudo-mkakudo)<180:
    kakudo = abs(hkakudo-mkakudo)
    ans = np.sqrt(a**2 +b**2 - 2*a*b*np.cos(np.pi*kakudo/180))
    print(ans)
else:
    kakudo = 360 - abs(hkakudo - mkakudo)
    ans = np.sqrt(a**2 +b**2 - 2*a*b*np.cos(np.pi*kakudo/180))
    print(ans)

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

p=2*math.pi

m_r = p*M/60
h_r = p*((H/12)+(M/60)/12)
d_r = abs(m_r - h_r)

C=A**2 + B**2 - 2*A*B*math.cos(d_r)
print(C**(1/2))

Solution (Python):
from math import cos,radians
a,b,h,m=map(int,input().split())
t=30*h
degr=min(abs(t-5.5*m),360-abs(t-5.5*m))

c=a**2+b**2-2*a*b*cos(radians(degr))
print(c**0.5)

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

Solution (Python):
import math

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

long_degree = M * 6
short_degree = H * 30 + (M * 0.5)

degree = abs(long_degree - short_degree)

if degree > 180:
    degree = 360 - degree

cos = math.cos(math.radians(degree))

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

print(str(ans))

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

day_min = 12 * 60
now_min = H * 60 + M

a_ang = now_min * 360 / day_min
b_ang = M * 6

tri_ang = min(abs(a_ang - b_ang), abs(a_ang - b_ang + 360), abs(a_ang - b_ang - 360))


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

Solution (Python):
import math

a,b,c,d = map(int,input().split())
x = ((c * (1/12)  * 360)+(d*(1/60)*30)) % 360
y = d * (1/60) * 360 % 360
Z = math.radians(abs(x-y))
zz = a**2 + b**2 - 2*a*b*math.cos(Z)
print(zz **(0.5))

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


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

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