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




angle = 0
l_angle = m * 6
s_angle = h * 30 + m * 0.5

if l_angle > s_angle:
  angle = l_angle - s_angle
else:
  angle = s_angle - l_angle

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

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

a = (H*30 + M*0.5 - 90) * (-1)
tena = math.sin(math.radians(a)) * A, math.cos(math.radians(a)) * A

b = (M*6 - 90) * (-1)
tenb = math.sin(math.radians(b)) * B, math.cos(math.radians(b)) * B
D = math.sqrt((tena[0]-tenb[0])**2 + (tena[1]-tenb[1])**2)
print(D)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
bk = 6 * m
ak = 30 * h + 0.5 * m
if ak >= bk + 180:
	k = 360 - ak + bk
elif bk >= ak + 180:
	k = 360 - bk + ak
elif bk > ak:
	k = bk - ak
else:
	k = ak - bk
ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(k)))
print(ans)

Solution (Python):
import math

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

h_angle = h * 30 + m * 0.5
m_angle = m * 6
angle = abs(h_angle - m_angle)
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle)))
print(c)

Solution (Python):
import math


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

m = M * 6
h = H * 30 + M * 0.5
s = min(abs(m-h), abs(h-m))

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

print(ans)

Solution (Python):
from math import pi,cos,sqrt
a,b,h,m = map(int,input().split())
hr = 0.5*(h*60+m)
mn = m*6
theta = abs(hr-mn)
angle = theta
angle = (angle*pi) / 180
ans = sqrt(a*a + b*b - 2*a*b*cos(angle))
print(round(ans,10))

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

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

Solution (Python):
import sys











 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod1=998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]








 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()] 
def LF(): return [float(x) for x in inp().strip().split()] 
def LS(): return inp().strip().split() 
def I(): return int(inp().strip()) 
def F(): return float(inp().strip()) 
def S(): return inp().strip() 
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a)) 
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r,p):                      
    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
    return t








def calcAngle(h,m): 
		if (h == 12): 
			h = 0
		if (m == 60): 
			m = 0
		hour_angle = 0.5 * (h * 60 + m) 
		minute_angle = 6 * m 
		angle = abs(hour_angle - minute_angle) 
		angle = min(360 - angle, angle) 
		return angle 

def main():
    from math import cos,sqrt,radians
    a,b,h,m=MI()
    x = calcAngle(h,m)
    
    x = radians(x)
    c = sqrt((a*a)+(b*b)-(2*a*b)*(cos(x)))
    print(c)





py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

inp = lambda: sys.stdin.readline().rstrip('\r\n')
out = lambda x: sys.stdout.write(x)
flsh= lambda: sys.stdout.flush()

if __name__ == "__main__":
    main()

Solution (Python):
import math


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

X=H*30+M*0.5
Y=M*6

t=(X-Y)*math.pi/180
print(math.sqrt(A**2+B**2-2*A*B*math.cos(t)))

Solution (Python):
import math
import numpy
list = list(map(int, input().split()))
jikaku = (30 * (list[2])) + (30 * (list[3]) / 60)
ax = list[0] * math.cos(math.radians(jikaku))
ay = list[0] * math.sin(math.radians(jikaku))

hunkaku = 6 * (list[3])
bx = list[1] * math.cos(math.radians(hunkaku))
by = list[1] * math.sin(math.radians(hunkaku))
print(numpy.linalg.norm(numpy.array([ax, ay]) - numpy.array([bx, by])))

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

h_c = 30*h + 0.5*m
m_c = 6*m

z = abs(h_c - m_c)
if z > 180:
  z = 360 - z
if z == 180:
  print(t[0]+t[1])
elif z == 0:
  print(abs(t[0]-t[1]))
else:
  a = a**2
  b = b**2
  k = round(math.cos(math.radians(z)),30)
  print(math.sqrt(a + b - 2*t[0]*t[1]*k))

Solution (Python):
import sys
import math

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

long = ((m/60)*360)
short = ((h/12+m/720)*360)

deruta = abs(long -short)



deruta = abs(math.radians(deruta))


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

print(c)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
if h > 12 :
    h -= 12
mnt = h * 60 + m
degA = mnt*math.pi/360
degB = m*math.pi/30
print(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(degA - degB)))

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

h_ang = 0.5* (h*60+m) 
m_ang = 6.0 * m

ang = math.fabs(h_ang-m_ang)

if ang > 180:
    ang = 360 - ang


if ang <= 90:
    ans = ((a*math.sin(math.radians(ang)))**2 + (b-a*math.cos(math.radians(ang)))**2)**0.5
else:
    ang = 180-ang
    ans = ((a*math.sin(math.radians(ang)))**2 + (b+a*math.cos(math.radians(ang)))**2)**0.5
print(ans)

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

angle = np.pi*abs(60*H-11*M)/360
x_2 = A**2+B**2-2*A*B*np.cos(angle)
x = np.sqrt(x_2)
print(x)

Solution (Python):
import math

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

a1 = math.pi*(60*h+m)/360
b1 = math.pi*m/30

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

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

Solution (Python):
import sys
import math

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    A, B, H, M = MI()
    th_h = (H / 12+ M / 720) * 360 
    th_m = M / 60 * 360 
    theta = abs(th_h-th_m)
    rad = math.radians(theta)
    ans2 = pow(A,2) + pow(B,2) - 2*A*B*math.cos(rad)

    print(pow(ans2,0.5))


if __name__ == "__main__":
	main()

Solution (Python):
import math 

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

theta = min(360-abs(6*m-30*h-0.5*m),abs(6*m-30*h-0.5*m))
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%12
th_h=30*h+0.5*m
th_m=6*m
theita=abs(th_h-th_m)
if theita<180:
    print('%.20f'%math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(theita))))
elif theita>180:
    theita=360-theita
    print('%.20f'%math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(theita))))
else:
    print(a+b)

Solution (Python):
import math

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

theta_h = 30*h + 0.5*m
theta_m = 6*m

theta = abs(theta_h - theta_m)

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

print(ans)

Solution (Python):
import math
import numpy as np
def resolver(A, B, H, M):
    minute = H * 60 + M

    thetaH = minute * math.pi * 2 / 60 / 12
    thetaM = M * math.pi * 2 / 60

    Hpoint = np.array((0, A))
    Mpoint = np.array((0, B))

    cosH = math.cos(thetaH)
    sinH = math.sin(thetaH)
    cosM = math.cos(thetaM)
    sinM = math.sin(thetaM)
    Hpoint = Hpoint * np.matrix([
        [cosH, -1 * sinH],
        [sinH, cosH]
    ])

    Mpoint = Mpoint * np.matrix([
        [cosM, -1 *sinM],
        [sinM, cosM]
    ])
    
    Hpoint = Hpoint.A[0]
    Mpoint = Mpoint.A[0]

    dx = Hpoint[0] - Mpoint[0]
    dy = Hpoint[1] - Mpoint[1]

    distance = math.sqrt(dx**2 + dy**2)

    print(distance)

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

    

    resolver(A, B, H, M)


if __name__ == '__main__':
    main()

Solution (Python):
import math

a,b,h,m = map(int,input().split())
zisin = (360/12)*h
zisin += 0.5*m
if zisin == 0:
    zisin = 360
hunsin = (360/60)*m
if hunsin == 0:
    hunsin = 360

if zisin == hunsin:
    print(abs(a-b))
    exit()
elif zisin > hunsin:
    cosa = zisin-hunsin
else:
    cosa = hunsin-zisin

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

ans = math.sqrt(ans)
print(ans)

Solution (Python):
import numpy as np

def get_angle(h, m):
  tmp_h = np.pi * h / 6 + np.pi * m / 360
  tmp_m = np.pi * m /30
  return abs(tmp_h - tmp_m)

def calc(a, b, h, m):
  angle = get_angle(h, m)
  return np.sqrt(a*a + b*b - 2*a*b*np.cos(angle))

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

Solution (Python):
import math
import numpy


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

    ar = 30 * (h) + 30 * (m / 60)
    br = 6 * (m)

    ay = math.sin(math.radians(-ar + 90)) * a
    ax = math.cos(math.radians(-ar+90)) * a

    by = math.sin(math.radians(-br+90)) * b
    bx = math.cos(math.radians(-br+90)) * b

    av = numpy.array([ax, ay])
    bv = numpy.array([bx, by])

    u = bv-av

    print(numpy.linalg.norm(u))
resolve()

Solution (Python):
def main():
    a,b,h,m = map(int,input().split())
    ji = 0.5*(h*60+m)
    fun = 6*m
    r = max(ji,fun)-min(ji,fun)

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

if __name__ == '__main__':
    main()

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

import math as mt
angle=max(30*h+0.5*m, 6*m)-min(30*h+0.5*m, 6*m)

if angle>180:
  angle=360-angle
  
d=a**2+b**2-2*a*b*mt.cos(mt.radians(angle))
c=mt.sqrt(d)
print(c)

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

C = min(abs((h * 60 + m) * 0.5 - m * 6), 360 - abs((h * 60 + m) * 0.5 - m * 6))

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

print(c)

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

thetaA = H*30+M/60*30
thetaB = M*6

diff = abs(thetaA-thetaB)
th = min(diff, 360-diff)
ans = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(th)))
print(ans)

Solution (Python):
import math

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


a_angle = (h/12 + m/(60*12)) *360
b_angle = m/60*360




line = 0

if a_angle > b_angle:
    angle = a_angle - b_angle
elif a_angle < b_angle:
    angle = b_angle - a_angle 
else:
    angle = 0


    
if angle >=180:
    angle = 360-angle



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

c = pow(c2, 1/2)
print(c)

Solution (Python):
import math


def main():
    A, B, H, M = map(int, input().split())
    alpha = 6 * M
    beta = (H * 30) + (M * 0.5)
    theta = math.radians(abs(alpha-beta))
    cos = math.cos(theta)
    ans = (A ** 2) + (B ** 2) - (2 * A * B * cos)
    print(math.sqrt(ans))


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

a_rad=30*h+m/2
b_rad=6*m

if a_rad==b_rad:
    print(abs(a-b))
elif abs(a_rad-b_rad)==180:
    print(a+b)
else:
    if abs(a_rad-b_rad)<180:
        rad=abs(a_rad-b_rad)
    else:
        rad=360-(abs(a_rad-b_rad))
    c=a**2+b**2-2*a*b*math.cos(math.radians(rad))
    print(math.sqrt(c))

Solution (Python):
import math
from math import cos

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

theta = abs(((H + M /60) * 30)-(M * 6))

print(pow(A**2+B**2-(2*A*B*cos(theta/180 * math.pi)),1/2))

Solution (Python):
import math

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

a_angle = 30 * h + 30 * m / 60
b_angle = 6 * m

angle = abs(a_angle - b_angle)
angle = min(360 - angle, angle)

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

Solution (Python):

import cmath

def main():
    a, b, h, m = map(int, input().split())
    h_ang = 2 * cmath.pi * (h / 12 + m / 12 / 60)
    m_ang = 2 * cmath.pi * m / 60

    h_cpl = cmath.rect(a, -h_ang)
    m_cpl = cmath.rect(b, -m_ang)
    ret = abs(h_cpl - m_cpl)
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
from math import cos, pi, sqrt
input = stdin.readline

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

x = (M * pi) / 30

y = (H * pi) / 6 + (M * pi) / 360

theta = max(x, y) - min(x, y)

if theta > 180:
    theta -= 180

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

print(sqrt(ans))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
t = 60*h+m
a_angl = (t%720) / 2
b_angl = (t%60) * 6

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

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

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

if (math.modf(minute/(180/5.5))[1])%2 ==0:
    theta = 5.5*(minute-math.modf(minute/(180/5.5))[1]*(180/5.5))
else:
    theta = 180 - 5.5*(minute-math.modf(minute/(180/5.5))[1]*(180/5.5))

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

Solution (Python):
from sys import stdin
import math
import numpy as np
from numpy.linalg import norm

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

two_pi = 2 * math.pi

hour_rad = - (two_pi / 12 * H + two_pi / (12 * 60) * M) + two_pi / 4
minute_rad = - (two_pi / 60) * M + two_pi / 4

hour = A * np.array([np.cos(hour_rad), np.sin(hour_rad)])
minute = B * np.array([np.cos(minute_rad), np.sin(minute_rad)])

div = hour - minute
print(norm(div))

Solution (Python):
import math
a,b,h,m = map(int, input().split())
anga = 30 * h + m / 2
angb = 6 * m
she = abs(min(anga - angb, 360 - (anga - angb)))
if she == 90:
  print(math.sqrt(a ** 2 + b ** 2))
elif she == 180:
  print(a + b)
else:
  length = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(she)))
  print(length)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
degree = abs(H - M*11/60)*math.pi/6
cosC = math.cos(degree)
ans = (A**2 + B**2 - 2*A*B*cosC)**(0.5)
print(ans)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
fai = 30 * h + 0.5 * m
sita = 6 * m
kakudo = abs(fai - sita)
print(((a ** 2) + (b ** 2) - (2 * a * b * math.cos(math.radians(kakudo)))) ** 0.5)

Solution (Python):
import math


def solve():
    A, B, H, M = map(int, input().split())
    Aa = H * (360 / 12) + M * (30 / 60)
    Ba = M * (360 / 60)
    a = abs(Aa - Ba)
    a = min(a, 360 - a)

    if a == 0:
        print(abs(A - B))
    elif a == 180:
        print(A + B)
    else:
        print(
            math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(a))))


if __name__ == '__main__':
    solve()

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

tyousin = M*6
tansin = H*30 + M*0.5

kakudosa = abs(tyousin - tansin)
if kakudosa >= 180:
    kakudosa = 360 - kakudosa

result_root = A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudosa))

print(math.sqrt(result_root))

Solution (Python):
import sys
import math

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline


pi = math.pi

def main():
    A, B, H, M = map(int, readline().split())
    Htmp = H*60+M
    h = (Htmp/(12*60))*2*pi; m = (M/60)*2*pi
    theta = min(abs(h-m), 2*pi-abs(h-m))
    
    ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta))
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

h_degree = 0.5*(H*60+M)
m_degree = 6*M

diff_degree = abs(m_degree-h_degree)
if diff_degree > 180:
  diff_degree = 360 - diff_degree
  
if diff_degree == 180:
    print(A+B)
elif diff_degree == 0:
    print(abs(A-B))
else:
    tmp = np.cos(np.deg2rad(diff_degree))
    print(np.sqrt(A**2+B**2-2*A*B*tmp))

Solution (Python):
import math
A, B, H, M = list(map(int,input().split()))
thetah = H * 30 + M * 1/60 * 30
thetam = M / 60 * 360
theta = min(abs(thetah - thetam), 360 - abs(thetah - thetam))
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=(int(x) for x in input().split())
theta=abs((6/360)*2*M*math.pi-(0.5/360)*2*(M+60*H)*math.pi)
if theta>math.pi:
    theta=2*math.pi-theta
ans=math.sqrt(A**2+B**2-2*A*B*math.cos(theta))
print(ans)

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

h=h%12
th_h=30*h+0.5*m
th_m=6*m
theita=abs(th_h-th_m)
if theita<180:
    print('%.20f'%math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(theita))))
elif theita>180:
    theita=360-theita
    print('%.20f'%math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(theita))))
else:
    print(a+b)

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

Solution (Python):
import numpy as np
pi = np.pi

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

short = 2*pi*(h*60+m)/720
long = 2*pi*m/60

if short <= long:
    ans = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(long - short))
else:
    ans = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(short - long))
    
print(ans)

Solution (Python):
import math
pi = math.pi
cos = math.cos
sin = math.sin
sqrt = math.sqrt

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

  short_rad = pi * h / 6 + pi * m / 360
  long_rad = pi * m / 30

  
  

  short_coordinate = [a * cos(short_rad), a * sin(short_rad)]
  long_coordinate = [b * cos(long_rad), b * sin(long_rad)]

  
  

  distance = sqrt((short_coordinate[0] - long_coordinate[0])**2 + (short_coordinate[1] - long_coordinate[1])**2)

  print(distance)

if __name__ == '__main__':
  main()

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

kaku = math.fabs(H/6 - 11*M/360) * 180
c_2 = A ** 2 + B ** 2 - 2 * A * B *  math.cos(math.radians(kaku))
print(c_2 ** 0.5)

Solution (Python):
import math

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



h_dig = 360 * (float(h) / 12) + 30 * (float(m) / 60)
m_dig = 360 * (float(m) / 60)



abs_dig = abs(h_dig - m_dig)
if(abs_dig > 180):
    abs_dig = 360 - abs_dig



c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(abs_dig / 360 * 2 * math.pi))

print('{:.09f}'.format(c))

Solution (Python):
import math

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

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

d2 = (A  * math.sin(sh) - B * math.sin(sm))**2
d2 += (A * math.cos(sh) - B * math.cos(sm))**2

ans = (d2)**0.5
print(ans)

Solution (Python):
import  numpy as np

def kaku(h,m):
    PI = 3.14159265358979323846
    hum = h * 60 + m
    rad = hum / 360 * PI
    return rad

def yogen(a, b, kaku):
    tmp = pow(a, 2) + pow(b, 2) - 2 * a * b * np.cos(kaku)
    return np.sqrt(tmp)
    

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

hour_rad = kaku(h, m)
min_rad = kaku(0, m) * 12
rad = abs(min_rad - hour_rad)
ans = yogen(a, b, rad)
   

print(ans)

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


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

Solution (Python):
import math

A, B, H, M = map(int,input().split())
Theta = 0 
a_radian=30*H+ 0.5*M
b_radian= 6*M
Theta=b_radian-a_radian
cosine_Theta=math.cos(math.radians(Theta))

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

print(str(x))

Solution (Python):
import math




















MOD = 10**9 + 7
A,B,H,M = map(int,input().split())

kakuH = 30 * H + 0.5 * M
kakuM = 6 * M

naiKaku = abs(kakuH-kakuM)

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

Solution (Python):
from  math import *
def a(m, h):
    return abs(h/ 6 - m / 30) * pi
a, b, h, m = map(int, input().split())

print(sqrt(a**2 + b**2 - 2*a*b*cos((h/ 6 + m/(360) - m / 30) * pi)))

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


print(ans)

Solution (Python):
import numpy as np
a,b,h,m=list(map(int,input().split()))
ta=(60*h+m)*0.5%360
tb=(60*h+m)*6%360
print(np.sqrt(a**2+b**2-2*a*b*np.cos(np.radians(tb)-np.radians(ta))))

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

m_angle = 6.0 * M
h_angle = 30.0 * H + 0.5 * M

theta = abs(h_angle - m_angle)
theta = min(theta, 360.0 - theta)
print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(theta))))

Solution (Python):
import math

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

mini = m+(h*60.0)

a_ang = 0.5*mini
b_ang = 6.0*m
ang = 0.0
flag = 0

if a_ang > b_ang:
    if a_ang-b_ang > 180:
        ang = 360.0 - (a_ang-b_ang)
    elif a_ang-b_ang < 180:
        ang = a_ang - b_ang
    else:
        print(a+b)
        flag = 1
elif a_ang < b_ang:
    if b_ang-a_ang > 180:
        ang = 360.0 - (b_ang-a_ang)
    elif b_ang-a_ang < 180:
        ang = b_ang - a_ang
    else:
        print(a+b)
        flag = 1
else:
    if a>b:
        print(a-b)
    else:
        print(b-a)
    flag = 1

if flag == 0:
    rad = math.radians(ang)
    print(math.sqrt((a**2)+(b**2)-(2*a*b*(math.cos(rad)))))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
HM = 60*h+m
atheta = 0.5*HM
btheta = (6*HM)%360
theta = min(abs(atheta-btheta), 360-abs(atheta - btheta))
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(theta))
print(c**0.5)

Solution (Python):
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7



a,b,h,m = MAP()

angleH = (h/12 + m/720) * 2 * pi
angleM = m/60 * 2 * pi

ax = sin(angleH) * a
ay = cos(angleH) * a
bx = sin(angleM) * b
by = cos(angleM) * b
width = max(ax, bx) - min(ax, bx)
height = max(ay, by) - min(ay, by)

print(math.sqrt(width * width + height * height))

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

mNum = map(int, input().split())
lNum = list(mNum)

minRad = 2 * pi * lNum[3] / 60
hourRad = 2 * pi * (lNum[2] * 60 + lNum[3]) / 720

minHand = numpy.array([lNum[1] * math.cos(minRad), lNum[1] * math.sin(minRad)])
hourHand = numpy.array([lNum[0] * math.cos(hourRad), lNum[0] * math.sin(hourRad)])

length = numpy.linalg.norm(hourHand - minHand)

print(length)

Solution (Python):
import math

n=list(map(int,input().split()))

A=n[0]
B=n[1]
H=n[2]
M=n[3]

A_rad=H*math.pi/6+M*math.pi/360
B_rad=M*math.pi/30


A_pos=[A*math.cos(A_rad),A*math.sin(A_rad)]
B_pos=[B*math.cos(B_rad),B*math.sin(B_rad)]

print(math.sqrt((A_pos[0]-B_pos[0])**2+(A_pos[1]-B_pos[1])**2))

Solution (Python):
import math
 
A,B,H,M = map(int,input().split())
s = 60*H+M
a = s*0.5
b = M*6
theta = 0
 
if abs(a-b)<=180:
    theta = abs(a-b)
else:
    theta = 360- abs(a-b)

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

Solution (Python):
import sys
import math
def get_array(): return list(map(int,sys.stdin.readline().strip().split()))
def get_ints(): return map(int,sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
a,b,h,m=get_ints()
a1=abs(h*30+m*0.5)-m*6 
ang=min(360-a1,a1)
ang1=math.radians(ang)
ans=a*a+b*b-2*a*b*math.cos(ang1)
print(math.sqrt(ans))

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

sh = (h * 60 + m) * 360 / (12 * 60) 
lo = 360 / 60 * m 
dif = abs(sh-lo)
ce = min(dif, 360-dif)

wa = a**2 + b**2
mi = 2 * a * b * math.cos(math.radians(ce))
aa = wa - mi
ans = pow(aa, 0.5)
print(ans)

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

time = h * 60 + m
hh = time * (360 / (12 * 60))
mm = time * (360 / 60)
deg = min(abs(hh - mm), 360 - abs(hh - mm))

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

print(math.sqrt(ans))

Solution (Python):
A,B,H,M=map(float,input().split())
from math import sin, cos, pi,sqrt

C = abs(30*H-5.5*M)
C = C if C <= 180 else 360-C
c =sqrt(A**2+B**2-2*A*B*cos(C*pi/180))
print(c)

Solution (Python):
import math
from math import ceil,sqrt,log,gcd,pi
def ii():return int(input())
def si():return input()
def mi():return map(int,input().split())
def li():return list(mi())



def calcAngle(h,m): 
          
    
    if (h < 0 or m < 0 or h > 12 or m > 60): 
        print('Wrong input') 
      
    if (h == 12): 
        h = 0
    if (m == 60): 
        m = 0
      
    
    
    
    hour_angle = 0.5 * (h * 60 + m) 
    minute_angle = 6 * m 
      
    
    angle = abs(hour_angle - minute_angle) 
    angle = min(360 - angle, angle) 
      
    return angle 
      
a,b,h,m=mi()
x=calcAngle(h,m)
if(x==0):
    print(abs(a-b))
    exit(0)
x=180/x
x1=math.cos(pi/x)

x=(a*a+b*b)-(2*a*b*x1)
print(sqrt(x))

Solution (Python):
import math

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

hm = 0.5
mm = 6

k = h*60+m

ha = k*hm % 360
ma = k*mm % 360

angle = abs(ha - ma)

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

Solution (Python):
import math

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

H_x = A*math.sin(math.radians(30*H+0.5*M))
H_y =  A*math.cos(math.radians(30*H+0.5*M))
M_x = B*math.sin(math.radians(6*M))
M_y =  B*math.cos(math.radians(6*M))
print(math.sqrt((H_x-M_x)**2+(H_y-M_y)**2))

Solution (Python):
import math

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

h_radius = 360 * h / 12 + 30 * m / 60
m_radius = 360 * m / 60

radius_diff = abs(h_radius - m_radius)

nagasa2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radius_diff))

print(math.sqrt(nagasa2))

Solution (Python):
import itertools
import math

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

H=H+M/60


Arad=2*math.pi / 12 * (3-H)
Ax=A*math.cos(Arad)
Ay=A*math.sin(Arad)



Brad=2*math.pi / 60 * (15-M)
Bx=B*math.cos(Brad)
By=B*math.sin(Brad)

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

print(Dist)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
hour = (H+M/60) / 12 * 360
minute = M / 60 * 360
deg=(max(hour, minute) - min(hour, minute)) % 360
if deg <= 180:
    pass
else:
    deg = 360 - deg

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

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

deg = abs(6*M-0.5*(60*H+M))
ans = (A**2 + B**2 - 2*A*B*math.cos(math.radians(deg))) ** (1/2)
print(ans)

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

d = max(h,m)-min(h,m)

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

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

hun = M * 6
zi = H * 30 + M * 0.5
cos = math.cos(math.radians(abs(zi - hun)))
print(math.sqrt(A * A + B * B - 2 * (A * B * cos)))

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

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

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

def angle(H, M):
  H_angle = H * 30 + (M/60)*30
  M_angle = M * 6
  if 360 - abs(H_angle - M_angle) > abs(H_angle - M_angle):
    return abs(H_angle - M_angle)
  else:
    return 360 - abs(H_angle - M_angle)

angle = angle(H, M)
ans = math.sqrt(A**2 + B**2 - 2*A*B* math.cos(math.radians(angle)))
print(ans)

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

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

Solution (Python):
import math

def calc(a, b, h, m):
    A = (h/12*360) + (m/60*30)
    B = m/60*360
    angle = abs(A-B)
    res = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(angle)))
    return res

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

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

angposmin=6*m
angposhour=(60*h+m)/2


m=min(a,b)
M=max(a,b)

angdiff=(2*math.pi*abs(angposmin-angposhour)/360)
diff= M-(math.cos(angdiff)*m)

p=math.sin(angdiff)*m


print(math.sqrt(diff*diff+p*p))

Solution (Python):
import numpy as np

a, b, h, m = [float(i) for i in input().split()]
kakua = 2*np.pi/12*h+2*np.pi/12*m/60
kakub = 2*np.pi/60*m
kaku = abs( kakua - kakub )
x = np.sqrt(a*a + b*b - 2*a*b*np.cos(kaku))
print(x)