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 time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()



A, B, H, M = In.ints()

hourstep = 360 / 12
minutestep = 360 / 60

hourX = 0
hourY = A

minuteX = 0
minuteY = B

hourX = hourY * sin(radians(hourstep*H) + radians(hourstep*(M/60)))
hourY = hourY * cos(radians(hourstep*H)+ radians(hourstep*(M/60)) )


minuteX = minuteY * sin(radians(minutestep*M))
minuteY = minuteY * cos(radians(minutestep*M))

res = sqrt((hourX-minuteX)**2+(hourY-minuteY)**2)
print(res)
    



if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Solution (Python):
import math

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

h = ((60*H+M)*0.5)%360
m = (6*M)%360

theta = abs(h-m)
len = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(theta)))
print(len)

Solution (Python):
import math

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

rad_A = 0.5 * (H * 60 + M)
rad_B = 6 * M
rad = abs(rad_A - rad_B - 360)
print(math.sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * math.cos(math.radians(rad))))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
xa = a * math.cos((h + m / 60.0) * 3.14159265358979323 / 6)
ya = a * math.sin((h + m / 60.0) * 3.14159265358979323 / 6)
xb = b * math.cos(m * 3.14159265358979323 / 30)
yb = b * math.sin(m * 3.14159265358979323 / 30)
print(math.sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb)))

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

c1 = (H/12+M/(60*12))*360
c2 = (M/60)*360

th = min(abs(c1-c2),abs(360-(c1-c2)))
th = (th / 180) * math.pi
print(math.sqrt((A**2)+(B**2)-2*A*B*math.cos(th)))

Solution (Python):
import numpy as np
a,b,h,m =  map(int,input().split())
w_h = 2*np.pi*((h+m/60)/12)
w_m = 2*np.pi*(m/60)
c_2 = a**2 + b**2 -2*a*b*np.cos(w_h-w_m)
print(c_2**0.5)

Solution (Python):
import math

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

x = math.fabs((H*60+M)*0.5 - M*6)

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

print(C)

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

Solution (Python):
import numpy as np
import math

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

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

k = abs(k_h-k_m)
if k >= 180:
  k = 360 - k

cos = math.cos(math.radians(k))
res = np.sqrt(a**2+b**2-2*a*b*cos)
print(res)

Solution (Python):

import math
a, b, h, m = map(int, input().split())
rad = math.radians(float(30*h - 5.5*m))
c = math.cos(rad)
print(math.sqrt(a**2+b**2-2*a*b*c))

Solution (Python):

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

M_r = 360/60 * M
H_r = 30 * H + 30/60 * M

C_r= abs(M_r - H_r)
C_r = min(C_r, 360-C_r)

C_2 = A**2 + B**2 - 2 * A * B * math.cos(math.radians(C_r))
C = math.sqrt(C_2)
print(C)

Solution (Python):
import math
a,b,h,m = (int(x) for x in input().split())
hour_deg = 2*h*math.pi/12 + m/60*math.pi/6
min_deg = 2*m*math.pi/60
diff_deg = min(hour_deg-min_deg, 2*math.pi-(hour_deg-min_deg))
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(diff_deg)))

Solution (Python):
import math
a,b,h,m=map(int,input().split())
k=360*(h*60+m)/720
n=360*m/60
rad=m-n
ans=(a**2+b**2-2*a*b*math.cos(2*math.pi*abs(k-n)/360))**0.5
print(str(ans)+"\n")

Solution (Python):
import math
a,b,h,m = map(int, input().split())
angleh = (30 * h + 0.5 * m) % 360
anglem = 6 * m % 360
if angleh > anglem:
    angle = angleh - anglem
else:
    angle = anglem - angleh
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(angle * math.pi / 180)))

Solution (Python):
import math

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

H_delta = H + M/60

xh = A * math.cos(2 * math.pi * H_delta/12)
yh = A * math.sin(2 * math.pi * H_delta/12)
xm = B * math.cos(2 * math.pi * M/60)
ym = B * math.sin(2 * math.pi * M/60)

dx = xh - xm
dy = yh - ym

result = (dx**2 + dy**2) ** (1/2)

print(result)

Solution (Python):
a, b, h, m = map(int, input().split())
a_theta = (30*h + 30*(m/60))%360
b_theta = (m/60)*360%360

import math

print('{:.15f}'.format(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(abs(a_theta - b_theta)/180*math.pi))))

Solution (Python):

from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


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

    print((a**2+b**2-2*a*b*math.cos(math.radians(30*h-(11/2.0)*m)))**(1/2))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math

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

thetaH=(H+M/60.0)/6.*math.pi
thetaM=M/30.0*math.pi

theta=abs(thetaH-thetaM)

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

print(ans)

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

b = M * 6
a = H*30 + M/2

c = min(abs(a-b), 360-abs(a-b))

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

Solution (Python):

from math import sin,cos,pi,sqrt
A,B,H,M=map(int,input().split())
a=(H/12+(1/12)*(M/60))*2*pi
b=(M/60)*2*pi

x1=A*cos(a)
y1=A*sin(a)
x2=B*cos(b)
y2=B*sin(b)

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

print(ans)

Solution (Python):
import numpy as np

a, b, h, m = map(int, input().split())
theta_h = 2 * np.pi * (h * 60 + m) / 720
theta_m = 2 * np.pi * m / 60
dx = a * np.cos(theta_h) - b * np.cos(theta_m)
dy = a * np.sin(theta_h) - b * np.sin(theta_m)
d = np.sqrt(dx ** 2 + dy ** 2)
print(d)

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

H_th = 2*np.pi/12*H + 2*np.pi/12/60*M
M_th = 2*np.pi/60*M

c = np.sqrt(A**2 + B**2 -2*A*B*np.cos(H_th-M_th))
print(c)

Solution (Python):
import math

A, B, H, M = [int(_) for _ in input().split()]
a_rad = ((H * 60 + M) / 720) * 2 * math.pi
b_rad = (M / 60) * 2 * math.pi
a_x = A * math.cos(a_rad)
a_y = A * math.sin(a_rad)
b_x = B * math.cos(b_rad)
b_y = B * math.sin(b_rad)
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
ar = h / 12 + m / 12 / 60
ax = a * math.cos(ar * 2 * math.pi)
ay = a * math.sin(ar* 2 * math.pi)
br = m / 60
bx = b * math.cos(br* 2 * math.pi)
by = b * math.sin(br* 2 * math.pi)




print(((ax - bx) ** 2 + (ay - by) ** 2) ** 0.5)

Solution (Python):
from math import *

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

main()

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

import math


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

thB=2*math.pi*M/60

listB=[B*math.sin(thB),B*math.cos(thB)]
listA=[A*math.sin(thA),A*math.cos(thA)]




print(((listB[0]-listA[0])**2+(listB[1]-listA[1])**2)**0.5)

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

import math
theta_a = (30.*H+0.5*M)/180 * math.pi
theta_b = (6.*M)/180 * math.pi

pa = [A*math.cos(theta_a), A*math.sin(theta_a)]
pb = [B*math.cos(theta_b), B*math.sin(theta_b)]

dis = math.sqrt((pa[0]-pb[0])**2+(pa[1]-pb[1])**2)
print(dis)

Solution (Python):
import numpy as np

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

Htheta = ((H%12)*60 + M)*0.5
Mtheta = M*6

degdef = abs(Htheta - Mtheta)* np.pi / 180
ans = np.sqrt(A**2 + B**2 - 2 * A * B * np.cos(degdef))
print(ans)

Solution (Python):
import sys
import math

sys.setrecursionlimit(10 ** 7)

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

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

H = H % 12
X = H * 60 + M

AX = X / 720.0 * 360
BX = M / 60.0 * 360

D = abs(AX - BX + (10 ** -12))

ANS = A ** 2 + B ** 2 - 2 * B * A * math.cos(math.radians(D))

print(math.sqrt(ANS))

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

r = abs((60*H-11*M)/2)

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

Solution (Python):
import math
A,B,H,M = map(float,input().split())
X = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(5.5*M-30*H)))
print(X)

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

Solution (Python):
from sys import stdin
import numpy as np
import math
A,B,H,M = [int(x) for x in stdin.readline().rstrip().split()]
a = 360*(H/12) + 360*(M/60)*(1/12)
b = 360*(M/60)
c = max(a,b) - min(a,b)
ans = A**2 + B**2 - 2*A*B*np.cos(math.radians(c))
print(np.sqrt(ans))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
theta_h = 2.5*math.pi - (2 * math.pi * ((h + (m/60))/12))
theta_m = 2.5*math.pi - (2 * math.pi *  (m/60) )

x_h = a * math.cos(theta_h)
y_h = a * math.sin(theta_h)
x_m = b * math.cos(theta_m)
y_m = b * math.sin(theta_m)

print(((x_h - x_m)**2 + (y_h-y_m)**2) ** 0.5)

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

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

H_rad = (H*60+M)/(12*60)*360
M_rad = M/60*360

H_x = A*math.cos(math.radians(H_rad))
H_y = A*math.sin(math.radians(H_rad))
M_x = B*math.cos(math.radians(M_rad))
M_y = B*math.sin(math.radians(M_rad))

X = H_x - M_x
Y = H_y - M_y

print(math.sqrt(X*X+Y*Y))

Solution (Python):
import math
A,B,H,M = map(int,input().split())
zisin = 360/12 * H + 30/60 * M
hunsin = 360/60 * M 
kakusa = min(abs(zisin - hunsin),abs(360-zisin+hunsin))*math.pi/180
ans_2 = A**2 + B**2 - 2*A*B*math.cos(kakusa)
print(ans_2**0.5)

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

h2 = (h+(m/60)) * 30
m2 = m * 6
x = abs(h2 - m2)

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

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

l = 6*m
s = 30*h + m/2
cos = math.cos(math.radians(l-s))
ans = a**2 + b**2 - 2*a*b*cos
print(ans**(1/2))

Solution (Python):

import math
A, B, H, M = map(int, input().split())
H = H * 30 + ((M / 60) * 30)
M = M * 6
deg = min(abs(H - M),360 - abs(H - M))
ans = A**2 + B**2 - (2 * A * B * math.cos(math.radians(deg)))
ans = ans**0.5
print(ans)

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

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

t = 60*h + m
w_a = 2*pi/12/60
w_b = 2*pi/60
fi_a = pi/2+w_a*t
fi_b = pi/2+w_b*t

xa = a * cos(fi_a)
ya = a * sin(fi_a)

xb = b * cos(fi_b)
yb = b * sin(fi_b)

dist = sqrt((xa - xb)**2 + (ya - yb)**2)

print(dist)

Solution (Python):
import math
import sys
a,b,h,m = map(int,input().split())
h_ = h*30 + (m/60) * 30
m_ = m*6
alpha = h_ - m_
if 0 < alpha < 180:
    pass
elif alpha == 180:
    print(a+b)
    sys.exit()
elif alpha == 0 or alpha == 360:
    print(abs(a-b))
    sys.exit()
else:
    alpha = 360 - alpha
ans_2 = a**2 + b**2 - 2 * b * a * math.cos(math.radians(alpha))
print(ans_2 ** 0.5)

Solution (Python):
from math import cos
from math import radians as rad
a,b,h,m=map(int,input().split())
s=a**2+b**2-2*a*b*cos(rad(30*h-5.5*m))
print(s**0.5)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
rad_a = 30 * H + 0.5 * M
rad_b = 6 * M
rad = abs(rad_a - rad_b)
cos = math.cos(math.radians(rad))


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

Solution (Python):
import numpy as np

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

  angle = min(np.abs(rad_a-rad_b), 2*np.pi-np.abs(rad_a-rad_b))
  ans_sq = a*a + b*b - 2*a*b*np.cos(angle)
  print(np.sqrt(ans_sq))

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

import numpy as np
cc=a*a+b*b-2*a*b*np.cos(2*np.pi/12*(h+m/60)-np.pi*m/30)
print(cc**0.5)

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




def main():
    a,b,h,m = map(int, input().split())
    theta = (m/60 - (60*h+m)/(60*12)) * 2 * pi
    print(sqrt(a**2+b**2-2*a*b*cos(theta)))

if __name__ == '__main__':
    main()

Solution (Python):
import math

def distance(x1, y1, x2, y2):
    dx = x1 - x2
    dy = y1 - y2
    return (dx**2 + dy**2)**0.5

lh, lm, h, m = map(int, input().split())

PI = math.pi

hx = math.cos(PI * 2 * (60 * h + m) / 720) * lh
hy = math.sin(PI * 2 * (60 * h + m) / 720) * lh
mx = math.cos(PI * 2 * m / 60) * lm
my = math.sin(PI * 2 * m / 60) * lm

print("%.20f"%(distance(hx, hy, mx, my)))

Solution (Python):





import numpy as np

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

theta = np.abs(h * 30. + 0.5 * m - m * 6.) / 180 * np.pi

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

Solution (Python):
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))


import math
a,b,h,m=l_in()

t1 = 2*math.pi*(h*60+m)/(12*60)
t2 = 2*math.pi*m/60

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

Solution (Python):
import math


length_hour, length_min, hour, minute = map(int, input().split(' '))
total_min = hour * 60 + minute

hx = math.sin((total_min / (12 * 60)) * (2 * math.pi)) * length_hour
hy = math.cos((total_min / (12 * 60)) * (2 * math.pi)) * length_hour
mx = math.sin((minute / 60) * (2 * math.pi)) * length_min
my = math.cos((minute / 60) * (2 * math.pi)) * length_min

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

print(f"{distance}")

Solution (Python):
import math

a, b, h, m = map(int, input().split())
theta = abs(6 * m - ((h*60)+m)*0.5)
theta = min(360-theta, theta)
ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(theta)))
print(ans)

Solution (Python):
import math
a,b,h,m=map(float,input().split())
h=h*math.pi/6.0
h=h+m/60*math.pi/6.0
m=m*math.pi/30.0
t=min(2*math.pi-abs(h-m),abs(h-m))
c=(a*a+b*b-2*a*b*math.cos(t))**0.5
print(c)

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

a, b, h, m = map(int, input().split())
mm = h * 60 + m
ag_s = 360 * (mm / (12*60))
ag_l = 360 * (m / 60)
theta = abs(ag_s - ag_l)
ans = sqrt(a**2 + b**2 - 2*a*b * cos(radians(theta)))
print(ans)

Solution (Python):
import math

a,b,h,m = map(int,input().split())
s = (h*60+m)/2
r = 6*m%360
if s>=r:
  d = math.cos(math.radians(s-r))
else:
  d = math.cos(math.radians(r-s))
kotae = math.sqrt(a**2+b**2-2*a*b*d)
print(kotae)

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

KakudoA = 2*math.pi*(H+M/60)/12
KakudoB = 2*math.pi*M/60

kakudobetween = min(abs(KakudoA-KakudoB), abs(2*math.pi+KakudoB-KakudoA))

if kakudobetween < 0.00000000000000000001:
	print(abs(B-A))
elif abs(kakudobetween - math.pi) < 0.000000000000000001:
	print(A+B)
else:
	print(math.sqrt(A**2+B**2-2*A*B*math.cos(kakudobetween)))

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

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

print(ans)

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

import math

x=abs(H/12+1/12*M/60-M/60)
x=min(x,1-x)
theta=2*math.pi*x
c=A**2+B**2-2*A*B*math.cos(theta)
print(math.sqrt(c))

Solution (Python):
import math

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



rad = abs(H % 12 * 30 + 0.5 * M - M * 6)

if rad > 180:
  rad = 360 - rad

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

Solution (Python):
import math

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

kakudo = 60*H - (11*M) 

ans2 = A**2 + (B**2) - 2*A*B*math.cos(math.pi*kakudo/360)
print("{:.15f}".format(math.sqrt(ans2)))

Solution (Python):
import numpy as np
import math
A, B, h, m = map(int, input().split())
rad_l = 2 * math.pi / 60 * m
rad_s = 2 * math.pi / 12 * h + 2 * math.pi / (12 * 60) * m
a = np.array([B * math.cos(rad_l), B * math.sin(rad_l)])
b = np.array([A * math.cos(rad_s), A * math.sin(rad_s)])
print(np.linalg.norm(a - b))

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

A,B,H,M=map(int,input().split())
ang_vel=[2*pi/(12*60), 2*pi/60]
minutes=H*60+M
ang1=ang_vel[0]*minutes
ang2=ang_vel[1]*M
theta=abs(ang1-ang2)

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

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

Solution (Python):
import math

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

jishin = 360 * (H + M/60) / 12
funshin = 360 * (M/60)

x_j = A * math.cos(math.radians(jishin))
y_j = A * math.sin(math.radians(jishin))

x_f = B * math.cos(math.radians(funshin))
y_f = B * math.sin(math.radians(funshin))

print(
  math.sqrt((x_j - x_f) ** 2 + (y_j - y_f) ** 2)
)

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

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

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

theta = max(h, m) - min(h, m)
if theta > 180:
  theta = 360 - theta

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

Solution (Python):
import math
A,B,H,M = map(int, input().split())
m = 60*H+M
degA = 0.5*m 
degB = (6*m)%360
xa = A*math.sin(math.radians(degA))
ya = A*math.cos(math.radians(degA))
xb = B*math.sin(math.radians(degB))
yb = B*math.cos(math.radians(degB))
ans = math.sqrt((xa-xb)**2+(ya-yb)**2)
print(ans)

Solution (Python):
import math

A,B,H,M = map(int,input().split())
a = H*30 + M/2
b = M*6
angle = math.radians(a-b)

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

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

Solution (Python):

import sys
import math

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(float, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

A, B, H, M = nm()


def solve():
    tb = M / 60.0 * (2 * math.pi)
    ta = (H + (M / 60.0)) / (12.0) * (2.0 * math.pi)
    C2 = A ** 2.0 + B ** 2.0 - 2.0 * A * B * math.cos(abs(tb - ta))
    return math.sqrt(C2)


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

Solution (Python):
from math import radians, cos

def main():
    a,b,h,m = map(int,input().split())
    A = (h*60+m)/720*360
    B = (h*60+m)/60*360%360
    x = radians(A-B)
    c = (a**2+b**2-2*a*b*cos(x))**0.5
    print("{:.12f}".format(c))
main()

Solution (Python):
import math

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

hrad = math.radians(h*30+m*0.5)
mrad = math.radians(m*6)

if hrad >= mrad:
	rad = min(hrad-mrad, 2*pi-(hrad-mrad))
else:
	rad = min(mrad-hrad, 2*pi-(mrad-hrad))

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

print(ans)

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

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

sa = np.abs(alpha-beta)
if sa >= np.pi:
    sa = 2*np.pi - sa
theta = sa
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())

ka = 2*math.pi*(h/12+(m/60)/12)
kb = 2*math.pi*(m/60)

k = ka - kb
if k >= math.pi:
    k = 2*math.pi - k

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

Solution (Python):
a,b,h,m = map(int,input().split())
import numpy as np 
x = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(np.pi*((h+m/60)/6 - m/30)))
print(x)

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

import numpy as np


d1  = np.pi*H/12*2+np.pi*M/12/60*2
d2  = np.pi*M/60*2

if d1 >= d2:
    deg = d1 - d2
else:
    deg = d2 - d1

deg = np.min([deg, 2*np.pi-deg])


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

Solution (Python):
import math

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

aa = h/6 * math.pi + (m/30 * math.pi)/12
bb = m/30 * math.pi
kakudo = max(aa, bb) - min(aa, bb)
x = a**2 + b**2 - 2*a*b*math.cos(kakudo)
print(math.sqrt(x))

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

Solution (Python):
import math

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.buffer.readline
    a,b,h,m = map(int, input().split())
    import numpy as np
    theta1 = np.pi*(h/6+m/360)
    theta2 = np.pi*m/30

    theta = min(abs(theta1-theta2), 2*np.pi-abs(theta1-theta2))
    c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(theta))
    print(c)


if __name__ == '__main__':
    main()

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

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

csq = a**2 + b**2 - 2*a*b*math.cos(abs(x-y))

print(math.sqrt(csq))

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

Solution (Python):
import math

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

θ = abs(30*h%360 + 0.5*m - 6*m%360)
c_2 = a**2 + b**2 - 2*a*b*math.cos(θ*math.pi/180)
print(math.sqrt(c_2))

Solution (Python):
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools

def hoge(n, m):
    n = n % 12
    b = 30*n+0.5*m
    s = 6*m
    ans = min(abs(b-s), 360-abs(b-s))
    if ans == 360:
        ans = 0
    return ans

def solve():
  a, b, h, n = map(int, input().split())
  p = hoge(h, n)
  ans = math.sqrt(a**2+b**2-(2*a*b*math.cos(math.radians(p))))
  print(ans)
  return 0
 
if __name__ == "__main__":
  solve()

Solution (Python):
import math

a, b, h, m = map(int, input().split())
a_deg = h * 30 + m * 0.5
b_deg = m * 6
deg = abs(a_deg - b_deg) if abs(a_deg - b_deg) <= 180 else 360 - abs(a_deg - b_deg)

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

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

kaku = min(abs(30*(H+M/60)-6*M),360-abs(30*(H+M/60)-6*M))
if kaku == 180:
    print(A+B)
    exit()
cos = math.cos(math.radians(kaku))

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

Solution (Python):
import math

abhm = [int(x) for x in input().split()]
a = abhm[0]
b = abhm[1]
h = abhm[2]
m = abhm[3]

angle = abs((6*m)-((h+(m/60))*30))
angle = angle/180*math.pi

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

Solution (Python):
import math

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

kakudo=h*30+m*0.5-m*6

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

import math
a,b,h,m=getNM()
pi=math.pi
thetah=pi/6*h+pi/30/12*m
thetam=pi/30*m

l=math.sqrt((a**2+b**2)-2*a*b*math.cos(thetah-thetam))
l2=math.sqrt((a**2+b**2)-2*a*b*math.cos(thetah-thetam))
print(l)

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


from math import pi
from math import sqrt
from math import cos
from math import radians

angle = abs(30 * (h + m / 60) - 6 * m)
c = sqrt(a**2 + b**2 - 2*a*b*cos(radians(angle)))
print(c)

Solution (Python):
from math import sin,cos,radians,sqrt
A,B,H,M = map(int,input().split())
a = H*(360/12) + M*(360/12/60)
b = M*(360/60)

A = [A*cos(radians(a)),A*sin(radians(a))]
B = [B*cos(radians(b)),B*sin(radians(b))]
x,y = A[0]-B[0],A[1]-B[1]

print(sqrt(pow(x,2)+pow(y,2)))

Solution (Python):

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

a1=2*pi*((h*60+m)/(12*60))
a2=2*pi*m/60
ans=a*a+b*b-2*a*b*cos(a1-a2)
print(sqrt(ans))

Solution (Python):
A, B , H, M = map(int, input().split())
import numpy as np
minute = np.array((B*np.cos(M/60*2*np.pi), B*np.sin(M/60*2*np.pi)))
hour = np.array((A*(np.cos((H/12+M/60/12)*2*np.pi)), A*(np.sin((H/12+M/60/12)*2*np.pi))))
vec = minute - hour
print(np.linalg.norm(vec))

Solution (Python):
a,b,h,m=map(int, input().split())
import math
b_angle=math.pi*(m*6/180)
a_angle=math.pi*((h+m/60)*30/180)
angle=abs(b_angle-a_angle)

if h==0 and m==0:
    print(abs(b-a))
elif angle==3.14159265359:
    print(a+b)
elif angle>0:

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

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

c2 = a**2 + b**2 - 2*a*b*math.cos(2*math.pi * (abs(hd-md)/360))



print(c2**0.5)

Solution (Python):
import math

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

bang = 2*math.pi * (m * (1/60))
aang = 2*math.pi * (h * (1/12) + m * (1 / 12 / 60) )



apos = (a*math.cos(aang), a*math.sin(aang))
bpos = (b*math.cos(bang), b*math.sin(bang))


lenx = apos[0]-bpos[0]
leny = apos[1]-bpos[1]

ablengh =lenx*lenx+leny*leny

ablengh = math.sqrt(ablengh)

print(ablengh)

Solution (Python):


import math


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


hour_kakudo = 360*(H/12) + 30*(M/60)
minute_kakudo = 360*(M/60)
kakudo = min(abs(hour_kakudo-minute_kakudo), 360-abs(hour_kakudo-minute_kakudo))
radian = math.radians(kakudo)


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


print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import math
    a,b,h,m=map(int, input().split())
    akaku=h*30+m*0.5
    bkaku=m*6
    kaku=max(akaku,bkaku)-min(akaku,bkaku)
    kaku=min(kaku,360-kaku)
    kaku1=math.cos(math.radians(kaku))
    xx=a**2+b**2-2*a*b*kaku1
    print(xx**0.5)
resolve()

Solution (Python):
import math

a, b, h, m = map(int, input().split())
i = (60 * h + m) / 2
j = 6 * m
t = i - j
if t > 180:
    t = (360 - i) + j
c = math.sqrt(math.pow(a, 2) + math.pow(b, 2) - 2 * a * b * math.cos(math.radians(t)))
print(c)

Solution (Python):
import math
a,b,h,m = map(int,input().split())
A = 30*h+m*30/60
B = 6*m
C = abs(A-B)

if C > 180:
    C = 360 - C
    
    
    c = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5
    print(c)
elif C < 180:
    c = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5
    print(c)
else:
    print(a+b)

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

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

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

import math

x=math.radians(30*h+m/2)
y=math.radians(6*m)
z=math.cos(y-x)

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

Solution (Python):
from math import radians, cos
a, b, h, m = map(int, input().split())
s = 30 * h + (1 / 2) * m
l = 6 * m
theta = radians(abs(s - l))
ans = (a ** 2 + b ** 2 - (2 * a * b * cos(theta))) ** (1 / 2)
print(ans)

Solution (Python):
import math

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

M_div = M / 60 * 360
H_div = H / 12 * 360 + M / 60 * 30

ans = (A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(M_div - H_div))) ** 0.5
print(ans)

Solution (Python):
import math
A,B,H,M = [int(i) for i in input().split()]
angle_A = 30*H + M/2
angle_B = 6*M
angle = angle_A - angle_B
C = A**2 + B**2 - 2*A*B*math.cos(math.radians(angle))
print(math.sqrt(C))

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

h = h + m / 60

theta = min(abs(h/6 - m/30)*math.pi, 2*math.pi - abs(h/6 - m/30)*math.pi)
s = math.sqrt(a**2+b**2-2*a*b*math.cos(theta))

print(s)

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

Solution (Python):

import sys
import math






tmp = input().split()
a,b,h,m = list(map(lambda a: int(a), tmp))

rad=abs(h*30+m/2-m*6)

if(rad>=180):
	rad=360-rad

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

print(math.sqrt(csq))

Solution (Python):
import math

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

a_radian = 2*math.pi*(h*60+m)/720
b_radian = 2*math.pi*m/60

ab = min(abs(a_radian-b_radian) , 2*math.pi-abs(a_radian-b_radian))

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

print(round(c,12))

Solution (Python):
import math

a, b, h, m = list(map(int, input().split()))
short = 2*math.pi*(h+m/60)/12
long = 2*math.pi*m/60
kakudo = min(abs(long-short), 2*math.pi-abs(long-short))

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

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

ans = math.sqrt(A**2+B**2-2*A*B*math.cos(math.pi*(60*H-11*M)/360))

print(ans)

Solution (Python):
import math
a, b, H, M = [int(i) for i in input().split()]
angle1 = (2 * math.pi / 12) * (H + M / 60)
angle2 = (2 * math.pi / 60) * M
res = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(angle2 - angle1))
print(res)

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