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 math import cos
from math import sin
from math import sqrt
from math import pi
from math import radians
A, B, H, M = map(int, input().split())
rad_long = (-360 * (M / 60) + 90)
rad_long = radians(rad_long)
rad_short = -30 * H - (M / 12) * 6 + 90
rad_short = radians(rad_short)


short_plot = [A * cos(rad_short), A * sin(rad_short)]
long_plot = [B * cos(rad_long), B * sin(rad_long)]



x = (short_plot[0] - long_plot[0])
y = (short_plot[1] - long_plot[1])


print(sqrt(x ** 2 + y**2))

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

p2 = 2.0 * pi

t1 = p2 / 12 * h + p2 / 12 / 60 * m
t2 = p2 / 60 * m



t = abs(t1 - t2)



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

print("{:.14f}".format(c))

Solution (Python):
def r2d(d):
    return d*360/2/math.pi

import math
a, b, h, m = map(int, input().split())
short = (h * (360 / 12)) + m * 1/2;

long = m * (360 / 60);

ang = abs(long - short);

ang = min(ang, (360 - ang))

res2 = a**2 + b**2 -2*a*b*math.cos(2*math.pi * (ang/360))

print(res2 ** 0.5)

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

aH = H*30 + M/2
aM = M*6

c = A**2+B**2-2*A*B*cos(radians(min(360-abs(aH-aM), abs(aH-aM))))

print(sqrt(c))

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

import math
c = m*6 - (60*h + m)*0.5
print((a**2+b**2-2*a*b*math.cos(math.radians(c)))**0.5)

Solution (Python):
import math

s = input().split()

a = int(s[0])
b = int(s[1])
h = int(s[2])
m = int(s[3])

h = (h + float(m / 60)) * 30

m = m * 6

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

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

print(result)

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

tanshin = h*(360/12)+(m/60)*(360/12)
tyoushin = m*(360/60)
kakudo = min(abs(tanshin-tyoushin), abs(tyoushin-tanshin))

print((a**2 + b**2 -2*a*b*math.cos(math.radians(kakudo)))**(1/2))

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

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

long_arch = H/12 + M/12/60
short_arch = M / 60

diff = abs(long_arch - short_arch)
smaller_diff = min(diff, 1-diff)

c2 = A*A + B*B - 2*A*B*cos(smaller_diff*2*pi)
print(sqrt(c2))

Solution (Python):
import sys
from pprint import pprint
import math

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

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

theta = h_theta - m_theta if h_theta >= m_theta else m_theta - h_theta 

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

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

kaku=abs(30*H-5.5*M)
rad=math.radians(kaku)


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

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
from collections import defaultdict
import math

A, B, H, M = map(int, input().split())
x1 = A * math.cos(math.pi/180*(90-360*H/12-30*M/60))
y1 = A * math.sin(math.pi/180*(90-360*H/12-30*M/60))
x2 = B * math.cos(math.pi/180*(90-360*M/60))
y2 = B * math.sin(math.pi/180*(90-360*M/60))
print(((x1-x2)**2+(y1-y2)**2)**0.5)

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

h_deg = (90 - ((360 / 12) * H + 30*M/60)) % 360
m_deg = (90 - (360 / 60) * M) % 360

h_rad = h_deg * (math.pi/180)
m_rad = m_deg * (math.pi/180)

h_x = A * math.cos(h_rad)
h_y = A * math.sin(h_rad)
m_x = B * math.cos(m_rad)
m_y = B * math.sin(m_rad)

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

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

at = (m + h*60) * 0.5
bt = m * 6

theta = abs(at - bt)
if theta > 180:
    theta = 360 - theta

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

print(c2**(1/2))

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

u = 360 * h / 12 + 30 * m / 60 
v = 360 * m / 60
z = abs(u - v)
if z > 180:
    z = 360 - z
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(z))

print(math.sqrt(c))

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

Solution (Python):
import math
A,B,H,M =map(int,input().split(" "))
h_deg = math.radians(30*H+0.5*M)
m_deg = math.radians(6*M)
hx_point = A*math.sin(h_deg)
hy_point = A*math.cos(h_deg)
mx_point = B*math.sin(m_deg)
my_point = B*math.cos(m_deg)
print(math.sqrt(abs(hx_point-mx_point)**2+abs(hy_point-my_point)**2))

Solution (Python):

import sys
import math

def position(l, d):
    x = l * math.sin(math.radians(d))
    y = l * math.cos(math.radians(d))
    return x, y

def solve(A: int, B: int, H: int, M: int):
    hour_deg = ((H*60+M)/720)*360
    min_deg = (M/60)*360

    hour_x, hour_y = position(A, hour_deg)
    min_x, min_y = position(B, min_deg)

    ans = math.sqrt((hour_x-min_x)**2+(hour_y-min_y)**2)

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    H = int(next(tokens))  
    M = int(next(tokens))  
    solve(A, B, H, M)

if __name__ == '__main__':
    main()

Solution (Python):
import math

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

degh = (h * 30) + (30 * m / 60)
degm = 6 * m

deg = math.radians(min(abs(degh - degm), 360 - abs(degh - degm)))



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

print(c)

Solution (Python):
import math

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

hour = H
if H <= 12:
  hour = H
else:
  hour = H - 12

minute = M;


rShort = (hour * (360 / 12)) + minute * 1/2;


rLong = minute * (360 / 60);


ang = abs(rLong - rShort);

kakudo = min(ang,(360 - ang))

cos = math.cos(math.radians(kakudo))

x = A**2 + B**2 - 2 * A * B * cos

print(x ** 0.5)

Solution (Python):
import math
a,b,h,m = map(int,input().split())
x = 0
y = 1
mkaku = (6*m)+90
hkaku = ((30*h)+(m/2))+90
posb = [b*math.sin(math.radians(float(mkaku))),b*math.cos(math.radians(float(mkaku)))]
posa = [a*math.sin(math.radians(float(hkaku))),a*math.cos(math.radians(float(hkaku)))]
yy = abs(posa[y]-posb[y])
xx = abs(posa[x]-posb[x])
print(math.sqrt(xx**2 + yy**2))

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

tan=30*h+0.5*m
cho=6*m
import math

kaku1=360+tan-cho
kaku2=tan-cho
x=min(kaku1,kaku2)
x=math.radians(x)
ccos=math.cos(x)
cc=a**2+b**2-2*a*b*ccos

print(math.sqrt(cc))

Solution (Python):
import math

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

asi = h * 30 + m / 2
bsi = m * 6

sita = abs(asi - bsi)

kotae = math.sqrt( a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(abs(asi-bsi))))
print(kotae)

Solution (Python):

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

a = (H+M/60)*math.pi/6
b = M*math.pi/30

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

Solution (Python):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)


def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    A, B, H, M = read_values()
    MM = H * 60 + M
    S = MM / (6 * 60) * math.pi
    T = M / 30 * math.pi
    print((A ** 2 + B ** 2 - 2 * A * B * math.cos(abs(S - T))) ** 0.5)


if __name__ == "__main__":
    main()

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

x = 360*(h/12)+30*(m/60)
y = 360*(m/60)

d = math.cos(math.radians(abs(x-y)))
z = a**2 + b**2 -2*a*b*d
print (math.sqrt(z))

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

Solution (Python):
import math

A, B, H, M = map(int, input().split())
r = (H * 30 + M * 0.5) - (M * 6)
if r > 180:
    r = 360 - r
ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(r))
print(math.sqrt(ans))

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

AA = 360 * H/12 + 30 * M/60
BB = 360 * M/60
if AA == BB:
    print(max(A-B,B-A))
elif AA > BB:
    cosC = math.cos(math.radians(AA-BB))
    print((A**2 + B**2 - 2*A*B*cosC)**0.5)
elif AA < BB:
    cosC = math.cos(math.radians(BB-AA))
    print((A**2 + B**2 - 2*A*B*cosC)**0.5)

Solution (Python):
def resolve():
    '''
    code here
    '''
    import math
    A, B, H, M = [int(item) for item in input().split()]

    h_ = 2*math.pi*(H*5 + M/60*5)/60
    m_ = 2*math.pi*(M/60)

    h_pos = [A*math.sin(h_), A*math.cos(h_)]
    m_pos = [B*math.sin(m_), B*math.cos(m_)]
    
    
    res = math.sqrt((h_pos[0]-m_pos[0])**2 + (h_pos[1]-m_pos[1])**2)
    print(res)
if __name__ == "__main__":
    resolve()

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


def main():
    a, b, h, m = map(int, input().split())
    theta = abs(6 * m - 0.5 * (60 * h + m))
    theta = min(theta, 360 - theta)
    if theta == 0:
        print(abs(b - a))
    elif theta == 180:
        print(a + b)
    else:
        print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theta * pi / 180)))


if __name__ == '__main__':
    main()

Solution (Python):
from math import sin, cos, radians
a, b, h, m = map(int, input().split())
x1, y1 = cos(radians(90 - 6*m))*b, sin(radians(90 - 6*m))*b
x2, y2 = cos(radians(90 - 30*h - m/2))*a, sin(radians(90 - 30*h - m/2))*a
print(((x2-x1)**2 + (y2-y1)**2)**0.5)

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

Solution (Python):
import itertools
from collections import defaultdict
import collections
import math
import sys
sys.setrecursionlimit(200000)
mod = 1000000007

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

subh = 30 * h
subh += 0.5 * m
subm = 6 * m

kakudo = min(abs(subh - subm), 360 - abs(subh - subm))
ans = a ** 2 + b ** 2 - ((2 * a * b) * (math.cos(math.radians(kakudo))))
print(math.sqrt(ans))

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]




import math
A, B, H, M = mi()

M_ratio = (M * 12 /60) /12
H_ratio = H / 12 + M_ratio / 12
k = 360 * abs(H_ratio-M_ratio)
k = min(k, 360-k)
k = math.radians(k)
print(math.sqrt(A**2+B**2-(2*A*B)*math.cos(k)))

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

long = m * 6
small = h * 30 + m * 0.5

kakudo = min(abs(long - small), 360-abs(small-long))

import math

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

print(ans)

Solution (Python):
import itertools as iter
import math as m

def main():
    A, B, H, M = list(map(int, input().split()))
    minute = 360 * M/60
    hour = 360 * H/12 + 30 * M/60

    C = abs(hour-minute)
    C = min(C, 360-C)
    ans = A**2+B**2-2*A*B*m.cos(m.radians(C))
    print(m.sqrt(ans))

if __name__ == '__main__':
    main()

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

    Sh = 360.0 * (H + M / 60.0) / 12.0
    Sm = 360.0 * M / 60.0
    S = 0.0
    
    
    
    if Sh == Sm :
        print(abs(A-B))
    elif Sh > Sm :
        S = Sh - Sm
        S = S * math.pi / 180.0
        c = (A * A + B * B - 2.0 * A * B * math.cos(S)) ** 0.5
        print(c)
    else :
        S = Sm - Sh
        S = S * math.pi / 180.0
        c = (A * A + B * B - 2.0 * A * B * math.cos(S)) ** 0.5
        print(c)

if __name__ == '__main__':
    main()

Solution (Python):
import math as m

A, B, H, M = map(int, input().split())
degreeH = H * 30 + M * 30 / 60
degreeM = 6 * M
degree = degreeH - degreeM
theta = m.radians(degree)

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

Solution (Python):
import math

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

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

s_cord = [A*math.sin(s_rad), A*math.cos(s_rad)]
l_cord = [B*math.sin(l_rad), B*math.cos(l_rad)]

length = math.sqrt( (s_cord[0]-l_cord[0])**2 + (s_cord[1]-l_cord[1])**2 )
print(length)

Solution (Python):




import math
A, B, H, M = map(int, input().split())
x = 360 * H / 12 + 30 * M / 60
y = 360 * M / 60

h = abs(x - y)

h = min(h, 360 - h)

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

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

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math

import itertools
import heapq


import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    a,b,h,m=map(int,input().split())
    akakudo=h*5+m/12
    bkakudo=m
    kakudosa=abs(akakudo-bkakudo)
    if kakudosa>=30:
        kakudosa=60-kakudosa
    bx=b*math.cos(math.radians(kakudosa*6))
    by=b*math.sin(math.radians(kakudosa*6))
    ans=math.sqrt((a-bx)**2+by**2)
    print(ans)



if __name__ == "__main__":

    main()

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

angle_h = (H + (M / 60)) / 12
angle_m = M / 60

if angle_h > angle_m:
    angle = (angle_h - angle_m) * 2 * math.pi
else:
    angle = (angle_m - angle_h) * 2 * math.pi

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

Solution (Python):
import math

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

h = 30 * H + 0.5 * M
m = 6 * M
kakudo = abs(h - m)

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

Solution (Python):


import math


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


PI = math.pi
angle_A = PI * H / 6 + PI * M / 360
angle_B = PI * M / 30
angle = max(angle_A, angle_B) - min(angle_A, angle_B)
result = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))


print(result)

Solution (Python):
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq

a, b, h, m = map(int, sys.stdin.readline().split())



x = (h * 60 + m) * 5.5
y = x % 360
c = min(y, 360-y)
d = math.radians(c)


e = (b * math.sin(d)) ** 2
f = (b * math.cos(d) - a) ** 2
ans = math.sqrt(e + f)
print(ans)

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

a_rad = ((t/(60*12)) - int(t/(60*12))) * (2*pi)
b_rad = ((t/(60)) - int(t/(60))) * (2*pi)
rad = abs(a_rad-b_rad)
ans = a**2+b**2 - 2*a*b*cos(rad)
print(ans**0.5)

Solution (Python):
import math

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

angA = (H*60 + M) * (360/(12*60))
angB = M * (360/60)
angle = math.radians(max([angA, angB]) - min([angA, angB]))
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))
print(C)

Solution (Python):
A,B,H,M=list(map(int,input().split()))
min_s=0.5*(H*60+M)
max_s=6*M
import math
radi=min(abs(max_s-min_s),360-abs(min_s-max_s))
ans=A**2+B**2-2*math.cos(math.radians(radi))*A*B
print(ans**0.5)

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

import math

a,b,h,m = MI()

t = 60*h + m


l = (t*6)%360


s = (t*0.5)%360


theta = min( abs(l-s), 360-abs(l-s) )


rad = math.radians( theta )


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

ans = math.sqrt(y)

print(ans)

Solution (Python):
import math

def main():
    
    
    math.radians(180)
    A, B, H, M = [int(x) for x in input().split()]
    m_rad = math.radians(M / 60 * 360)
    h_rad = math.radians((H*60 + M) / 720 * 360)
    c2 = A**2 + B**2 - (2 * A * B * math.cos(m_rad - h_rad))
    print(math.sqrt(c2))

if __name__ == "__main__":
    main()

Solution (Python):
import math
A,B,H,M = list(map(int,input().split()))
time = H * 60 + M
Arad = 360 * time/720
Brad = 360 * M / 60
ans = A*A + B*B - 2*A*B*math.cos(math.radians(abs(Arad-Brad)))
print(ans**(1/2))

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

ji_arg = (h * 30) + (m / 2)
hun_arg = 6 * m
if abs(ji_arg - hun_arg) <= 180:
    c = abs(ji_arg - hun_arg) * math.pi / 180
    x = a ** 2 + b ** 2 - 2 * a * b * math.cos(c)
    x = math.sqrt(x)
    print(x)
else:
    c = abs(360 - ji_arg + hun_arg) * math.pi / 180
    x = a ** 2 + b ** 2 - 2 * a * b * math.cos(c)
    x = math.sqrt(x)
    print(x)

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

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
h %= 12
h *= 60
h = h + m
ma = m * 6
ha = h * 0.5
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(min(ma-ha,ha-ma)))))

Solution (Python):
from math import cos, radians
def solve(A, B, H, M):
    theta_a = (H + M / 60) * 30
    theta_b =  M * 6
    theta = min(abs(theta_a - theta_b), 360 - abs(theta_a - theta_b))
    a = [A**2, B**2, cos(theta)]
    return (A**2 + B**2 - 2 * A * B * cos(radians(theta)))**(1/2)

if __name__ == "__main__":
    A, B, H, M = map(int, input().split())
    print(solve(A, B, H, M))

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

C = abs(30*h-11*m/2)
W = C*math.pi/180

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

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

a_angle = (H * 30 + M * 0.5) 
b_angle = 6*M


angle = abs(b_angle - a_angle)
if angle >= 180:
    angle = 360 - angle
    
cos_ab = math.cos(math.radians(angle))
print(math.sqrt(math.pow(A, 2) + math.pow(B, 2) - 2 * A * B * cos_ab))

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

ke=(h*60+m)*5.5/360
ke=(ke-int(ke))*math.pi*2
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(ke))
print(ans)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
h += m/60.0
a_x = a*math.sin((h/12.0)*2.0*math.pi)
a_y = a*math.cos((h/12.0)*2.0*math.pi)
b_x = b*math.sin((m/60.0)*2.0*math.pi)
b_y = b*math.cos((m/60.0)*2.0*math.pi)
dist = math.sqrt((a_x - b_x)*(a_x - b_x) + (a_y - b_y)*(a_y - b_y))
print(dist)

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


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

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

Solution (Python):
import fractions
pi = fractions.math.pi

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

Tl = 2*pi*M/60
Ts = 2*pi*(H+M/60)/12

Theta = abs(Tl-Ts)
if Theta > pi:
  Theta = 2*pi - Theta

C2 = A**2 + B**2 - (2*A*B*fractions.math.cos(Theta))
print(fractions.math.sqrt(C2))

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

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

hun_kaku = 6*M
zi_kaku = 30*H+0.5*M
kakudo = min(abs(hun_kaku-zi_kaku),360-abs(hun_kaku-zi_kaku))

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

Solution (Python):



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





A_kakudo = 360* (H/12 + M/720)

B_kakudo = 360* (M/60)


AB_kakudo = abs(A_kakudo - B_kakudo)

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

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

Solution (Python):
import math
a,b,h,m = (int(x) for x in input().split())
angle = abs(math.pi*(h*60+m)/360 -math.pi*m/30)
ans = a**2 + b**2 - 2*a*b*math.cos(angle)
print(ans**(1/2))

Solution (Python):
import math

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

a_speed = 0.5 
b_speed = 6    

a_point = 30*h + a_speed*m
b_point = b_speed*m
if a_point > b_point:
    degree = a_point - b_point
else:
    degree = b_point-a_point
    
degree = min(degree, 360-degree)
feature = (a**2+b**2)-2*b*a*math.cos(math.radians(degree))
print(feature**0.5)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
ga=math.radians(90-30*(h+m/60))
gb=math.radians(90-6*m)
xa=a*math.cos(ga)
ya=a*math.sin(ga)
xb=b*math.cos(gb)
yb=b*math.sin(gb)
print(math.sqrt((xa-xb)**2+(ya-yb)**2))

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

Solution (Python):
import math
A, B, H, M = [ int(i) for i in input().strip().split(' ')]

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

hx = A * math.cos(math.radians(h - 90))
hy = A * math.sin(math.radians(h - 90))
mx = B * math.cos(math.radians(m - 90))
my = B * math.sin(math.radians(m - 90))

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

Solution (Python):
import math
A,B,H,M = map(int,input().split())	
hun = H*60 + M
doji = (hun / 720)*360

dohun = (M/60)*360

if abs(doji - dohun) <= 180 :
    ans = A**2+B**2-2*A*B*math.cos(math.radians(abs(doji-dohun)))
elif doji - dohun >=0:
    ans = A**2+B**2-2*A*B*math.cos(math.radians(360-doji+dohun))
else:
    ans = A**2+B**2-2*A*B*math.cos(math.radians(360-dohun+doji))

print(math.sqrt(ans))

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

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

theta = abs(30*H+M/2-6*M)
if theta == 180:
    print(A+B)
else:
    if theta > 180:
        theta = 360-theta

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

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
H = 30*h+0.5*m
M = 6*m
if 0<=H<=90:
    H = (90-H)
else:
    H = 450-H
if 0<=M<=90:
    M = (90-M)
else:
    M = 450-M
x_1 = math.cos(math.radians(H))*a
y_1 = math.sin(math.radians(H))*a
x_2 = math.cos(math.radians(M))*b
y_2 = math.sin(math.radians(M))*b
X = abs(x_1-x_2)
Y = abs(y_1-y_2)
dis = math.sqrt(X**2+Y**2)
print(dis)

Solution (Python):
import math

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

m += h * 60

num_a = m * 0.5
num_b = m * 6 % 360

theta = abs(num_a - num_b)
rad = math.radians(theta)

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

Solution (Python):
import math

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

h_theta = -min(H, 12) * 30 + 90. - M * 0.5
m_theta = -M * 6 + 90.
h_theta = math.radians(h_theta)
m_theta = math.radians(m_theta)


h_x, h_y = A*math.sin(h_theta), A*math.cos(h_theta)
m_x, m_y = B*math.sin(m_theta), B*math.cos(m_theta)

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

print(ans)

Solution (Python):

import sys
import math


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    A, B, H, M = IL(int)
    A_x = A * math.cos(2 * math.pi * (H * 60 + M) / 12 / 60)
    A_y = A * math.sin(2 * math.pi * (H * 60 + M) / 12 / 60)
    B_x = B * math.cos(2 * math.pi * M / 60)
    B_y = B * math.sin(2 * math.pi * M / 60)
    print(math.sqrt((A_x - B_x) ** 2 + (A_y - B_y) ** 2))
    
    


solve()

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

Solution (Python):
import math

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

omega_h = 360/720
omega_m = 360/60

min = H * 60 + M

theta_h = omega_h * min
theta_m = (omega_m * min) % 360
theta = theta_h - theta_m


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

Solution (Python):
import math


a, b, h, m = map(int, input().split(" "))
ltheta = (h + m / 60.)* 30
mtheta = m * 6


theta_diff = abs(ltheta-mtheta)
theta_diff = min(360-theta_diff, theta_diff)

theta_diff = math.pi / 180 * theta_diff
theta = theta_diff

x = a - b * math.cos(theta)
y = b * math.sin(theta)
out = math.sqrt( (x ** 2) + (y ** 2))

print(out)

Solution (Python):
import math

a = list(map(int,input().split()))
A = a[0]
B = a[1]
H = a[2]
M = a[3]
x = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(6*M - 30*H -  0.5*M)))
print(x)

Solution (Python):
import math
a, b, h, m = map(float, input().split())
ji = ((60 * h + m) / 720) * 2 * math.pi
hu = (m / 60) * 2 * math.pi
kaku = abs(ji - hu)
ans = (a ** 2 + b ** 2 - 2 * a * b * math.cos(kaku)) ** (1/2)
print(ans)

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

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

diff_deg = math.fabs(6 * M - (60 * H + M)/2)
print(math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(diff_deg))))

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



radh = math.radians(thetah)
radm = math.radians(thetam)

x1, y1 = a * math.sin(radh), a * math.cos(radh)
x2, y2 = b * math.sin(radm), b * math.cos(radm)

print(math.sqrt( (x1-x2)**2 + (y1-y2) ** 2))

Solution (Python):
import math

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

a,b,h,m = intMap()




radH = h * math.pi / 6 + m * math.pi / 360
radM = m * math.pi / 30

xH = a * math.sin(radH)
yH = -a * math.cos(radH)

xM = b * math.sin(radM)
yM = -b * math.cos(radM)

x2 = (xH-xM) * (xH-xM)
y2 = (yH-yM) * (yH-yM)
d = math.sqrt(x2+y2)

print(d)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
h, m = h * 30 + m / 2, m * 6
angle = abs(h - m)
ans2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle))
print(math.sqrt(ans2))

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
import math


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

def get_len(a, b, deg):
    rad = deg * math.pi / 180
    return (a**2 + b**2 - 2*a*b*math.cos(rad))**0.5


deg_A = 0.5 * (M + H*60)
deg_B = M * 360 / 60

deg = abs(deg_A - deg_B)
print(get_len(A, B, deg))

Solution (Python):
import math

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

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos((11*m/360 - h/6)*math.pi))
print(ans)

Solution (Python):
import math
import numpy

line = input().split()

a = int(line[0])
b = int(line[1])
h = int(line[2])
m = int(line[3])

h_r = math.pi * (0.25 - (2 * (h + m / 60) / 12))
m_r = math.pi * (0.25 - (2 * m / 60))

l = numpy.sqrt((a * math.cos(h_r) - b * math.cos(m_r)) ** 2 + (a * math.sin(h_r) - b * math.sin(m_r)) ** 2)
print(l)