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,c,d = map(float,input().split())
 
H = 30
M = 6
 
HM = 0.5
 
kakudo = abs((c*H+d*HM) - d*M)
 
if kakudo == 180:
  print(a+b)
elif kakudo == 0:
  print(abs(a-b))
else:
  print(math.sqrt(pow(a,2) + pow(b,2) - 2*a*b*math.cos(math.radians(kakudo))))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
A = (h * 60 + m) * 360 / (12 * 60)
B = 6 * m
C = abs(A - B)

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

Solution (Python):
import math

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

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

rad = abs(h-m)
cosrad = math.cos(math.radians(rad))
c2 = a**2 + b**2 - 2*b*a*cosrad
c2 = c2 ** 0.5

print(c2)

Solution (Python):
import math

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

a_detect = 360 * h / 12 + 360 / 12 * m / 60

b_detect = 360 * m/60

diff = a_detect - b_detect
if diff < 0 :
  diff = -diff
diff -=180
if diff < 0 :
  diff = -diff

nagasa = int(a)**2 + int(b)**2 + 2* int(a)*int(b)*math.cos(math.radians(diff))
nagasa = math.sqrt(nagasa)


print(nagasa)

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

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

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

Solution (Python):
import math
a,b,h,m=[int(x) for x in input().rstrip().split()]
now_h=h*60*0.5+m*0.5
now_m=m*6





kakudo=(abs(now_h-now_m))
kakudo=math.cos(math.radians(kakudo))

print((a**2+b**2-2*a*b*kakudo)**0.5)

Solution (Python):
import math

def clockangles(hour, minute):
    ans = abs((hour * 30 + minute * 0.5) - (minute * 6))
    return min(360-ans,ans)

a, b, h, m = input ().split() 
a = float (a)
b = float (b)
h = float (h)
m = float (m)
angle = math.cos (clockangles (h, m) * math.pi / 180.0) 
ans = ((a ** 2) + (b ** 2) - ((2 * a * b) * angle))
print (math.sqrt(ans))

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

angle = abs(hour_angle - minute_angle)
angle = min(360.0 - angle, angle)
ans= (a*a) + (b*b) - (2.0*a*b*math.cos(angle * math.pi /180))
ans = math.sqrt(ans)
print(ans)

Solution (Python):
import math
from decimal import *

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

a_kakudo=30*h+30*(m/60)
b_kakudo=6*m

kakudo=abs(a_kakudo-b_kakudo)

if kakudo==0:
  print(abs(a-b))
  exit()

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

Solution (Python):
import math

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

time_angle = float((H*60+M)/2)
minu_angle = float(6*M)

angle = abs(time_angle - minu_angle)

if angle > 180:
  angle = 360-angle

if angle == 180:
  length = A+B
elif angle == 90:
  length = math.sqrt(A*A+B*B)
else:
  angle = angle*math.pi/180
  length = math.sqrt((A*A)+(B*B)-(2*A*B*math.cos(angle)))

print(length)

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

RA = (H * 60 + M) / 720 * 360
RB = M / 60 * 360

rad = abs(RA - RB)

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

print(abs(math.sqrt(sq)))

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

Solution (Python):
import math
import decimal
decimal.getcontext().prec = 11
a,b,h,m = map(int,input().split())
cost = math.cos(math.radians(30*h-5.5*m))
l = decimal.Decimal((a**2+b**2-2*a*b*cost)**(1/2))
print(l)

Solution (Python):

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

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

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

x = 30 * h + 0.5 * m
y = 6 * m % 360

kaku = min(abs(x-y), 360 - abs(x-y))

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

print (ans)

Solution (Python):
a,b,h,m=map(int,input().split())
from cmath import rect,pi
print(abs(rect(b,m*pi/30)-rect(a,(h+m/60)*pi/6)))

Solution (Python):
import math
def a():
    n = int(input()) % 10
    if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        print('hon')
    elif n == 3:
        print('bon')
    else:
        print('pon')




def b():
    k = int(input())
    s = input()
    if len(s) <= k:
        print(s)
    else:
        print(s[:k] + '...')

def c():
    a, b, h, m = map(int, input().split())
    deg = abs(360 * m / 60 - 360 * (h / 12 + m / 720))
    print(pow(pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(math.radians(deg)), 0.5))
    
    





c()

Solution (Python):
import math
a,b,c,d = input().split(" ")
a = int(a)
b = int(b)
c = int(c)
d = int(d)
t1 = 30*c + 0.5*d
t2 = 6*d
e = math.cos(math.radians(t1-t2))
f = a*a + b*b - 2*a*b*e
print(f ** 0.5)

Solution (Python):
import sys
import math

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007



def main():
	
	a, b , h, m = tin()
	
	pi=3.14159265358979633
	tan = ((30 * h + 0.5*m)*2*pi)/360
	tyou = (6 * m*2*pi)/360
	tan_x = math.cos(tan)*a
	tan_y = math.sin(tan)*a
	tyou_x = math.cos(tyou)*b
	tyou_y = math.sin(tyou)*b
	r2 = (tan_x-tyou_x)**2
	r2 += (tan_y - tyou_y)**2
	ret = r2**0.5
	print(ret)
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
import math
def C():
    A, B, H, M = map(int, input().split())
    h = 360*H//12 + 360//12*(M/60)
    m = 360*M//60
    angle = abs(h-m)
    print(math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(angle))))
    
C()

Solution (Python):
import math as mt
a, b, h, m = map(float, input().split())
radm = 90 - 6 * m
radh = -m/2 + 90 - 30 * h
radm, radh = mt.radians(radm), mt.radians(radh)
mx, my = b*mt.cos(radm), b*mt.sin(radm)
hx, hy = a*mt.cos(radh), a*mt.sin(radh)
ans = (mx-hx)*(mx-hx) + (my-hy)*(my-hy)
print(mt.sqrt(ans))

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

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

Solution (Python):
import math
a,b,x,y=map(int,input().split())
angle=(y*6) - (x + (y/60))*30
angle*=((math.pi)/180)
print((a**2 + b**2 - 2*a*b*math.cos(angle))**0.5)

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


def main():
    l = [int(e) for e in si().split()]
    a, b, h, m = l[0], l[1], l[2], l[3]
    h = h/12*360+m/60*360/12
    m = m/60*360
    if m > h:
        m, h = h, m
    ang = (h-m)/360*math.pi*2
    if a > b:
        a, b = b, a
    print(math.sqrt(b**2+a**2-2*a*b*math.cos(ang)))


if __name__ == '__main__':
    main()

Solution (Python):
import numpy
import math

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


mkaku = m*6
hkaku = h*30 + 0.5*m

if hkaku == mkaku:
    if a > b:
        print(a-b)
    else:
        print(b-a)
elif hkaku > mkaku:
    kaku = hkaku - mkaku
    if kaku > 180:
        kaku =  360 - kaku



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

else:
    kaku = mkaku - hkaku
    if kaku > 180:
        kaku = 360 - kaku 
    


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

Solution (Python):
import math
pi=math.pi
def cal_h_hand_arg(h,m):
  arg=2*pi*h/12.0+2*pi*(1/12.0)*(m/60.0)
  return arg
def cal_m_hand_arg(m):
  arg=2*pi*(m/60)
  return arg

A,B,H,M=map(float,input().split())
h_arg=cal_h_hand_arg(H,M)
m_arg=cal_m_hand_arg(M)
diff_arg=abs(h_arg-m_arg)
if diff_arg > pi:
  diff_arg=2*pi-diff_arg
ans=A**2+B**2-2*A*B*math.cos(diff_arg)
print(math.sqrt(ans))

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

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

l = a**2 + b**2 - 2*a*b*math.cos(math.radians(5.5*(h*60+m)))
print(math.sqrt(l))

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

angle = abs(30* H - 5.5 * M)
if angle > 180:
  angle = 360 - angle

ans = np.sqrt((A**2 + B**2) - (2 * A * B * np.cos(np.radians(angle))))
print(ans)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
tan = 30 * H + (30 * (M / 60))
tyo = 6 * M
kakudo = abs(tan - tyo)
ans = pow(A, 2) + pow(B, 2) - 2 * A * B * math.cos(math.radians(kakudo))
print(pow(ans, 0.5))

Solution (Python):

import sys
import itertools

DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False


def dp(value):
    if DEBUG:
        print(value)
    return


def input_text(split=" "):
    
    result = []
    while True:
        try:
            row = list(
                map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
            )
            result.append(row)
        except EOFError:
            break
    return result



it = input_text()

a = it[0][0]
b = it[0][1]
h = it[0][2]
m = it[0][3]

import math

hs = (h / 12 + m / 60 / 12) * 2 * math.pi
ms = (m / 60) * 2 * math.pi

hx = a * math.cos(hs)
hy = a * math.sin(hs)
mx = b * math.cos(ms)
my = b * math.sin(ms)

r = math.sqrt(pow(hx - mx, 2) + pow(hy - my, 2))
print(r)

Solution (Python):
import sys
import math

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




c = abs((H * 30 + M * 0.5) - (M * 6))
if c > 180:
    c = 360 - c
print(math.sqrt(A**2 + B**2 - (2 * A * B * math.cos(math.radians(c)))))

Solution (Python):


import math







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

    vh = ((H * 60 + M) / (12 * 60))
    vm = (M / 60)

    theta = (vh - vm) * math.tau
    d = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))

    print(d)

if __name__ == "__main__":
    main()

Solution (Python):
from math import cos,radians
a,b,h,m = map(int,input().split())
 
 
mne = (360/60)*m
hne = (360/12)*h + (30*(mne/360))

if hne == mne:
    print(abs(a-b))
    exit()
elif abs(hne - mne) == 180:
    print(a+b)
    exit()
elif hne > mne:
    theta = hne - mne
else:
    theta = mne -hne
 
theta = min(theta,360-theta)
 
t = cos(radians(theta))
print((((a**2)+(b**2))-(2*a*b*t))**(1/2))

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

dig_h = 0
if (60 * h + m) / 2 <= 90:
    dig_h = 90 - (60 * h + m) / 2
else:
    dig_h = 450 - (60 * h + m) / 2
rad_h = math.radians(dig_h)
A = [a * math.cos(rad_h), a * math.sin(rad_h)]


dig_m = 0
if (6 * m) <= 90:
    dig_m = 90 - 6 * m
else:
    dig_m = 450 - 6 * m
rad_m = math.radians(dig_m)
B = [b * math.cos(rad_m), b * math.sin(rad_m)]


ans = math.sqrt((A[0] - B[0]) ** 2 + (A[1] - B[1]) ** 2)
print(ans)

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


def main():
  a, b, h, m = map(int, input().split())
  
  ar = PI/2 - 2 * PI / 12 * h - 2 * PI / 60 / 12 * m 
  br = PI/2 - 2 * PI / 60 * m
  
  ax, ay = a * cos(ar), a * sin(ar)
  bx, by = b * cos(br), b * sin(br)
  
  c = sqrt((ax - bx) ** 2 + (ay - by) ** 2)
  
  print(c)
  
  
  
if __name__ == '__main__':
  main()

Solution (Python):
import math
a,b,h,m=map(int,input().split())
d=h*60+m
a2=d/720
b2=m/60
d2=((a2-b2)**2)**0.5


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

Solution (Python):
import math
[A,B,H,M] = input().split()
A = int(A)
B = int(B)
H = int(H)
M = int(M)
H_theta = H / 6 * math.pi
M_theta = M / 30 * math.pi
H_theta += M_theta / 12
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(abs(H_theta-M_theta)))
print(ans)

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

X1 = A * (math.sin(math.radians(0.5 * (H*60+M))))
Y1 = A * (math.cos(math.radians(0.5 * (H*60+M))))

X2 = B * (math.sin(math.radians(6 * M)))
Y2 = B * (math.cos(math.radians(6 * M)))

R = math.sqrt((X1-X2)**2 + (Y1 - Y2) ** 2)
print(R)

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

theta = abs(30*H+(M/2)-6*M)
theta = min(theta, 360-theta)
theta = math.radians(theta)

X2 = pow(A,2)+pow(B,2)-2*A*B*math.cos(theta)
print(math.sqrt(X2))

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

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

th = float(((H * 60 + M) * 5.5 % 360) * pi / 180)

print(sqrt(A*A + B*B - 2*A*B*cos(th)))

Solution (Python):
A, B, H, M = map(int, input().split())
hun = 6*M
ji = 30*H + 0.5*M
sa = hun-ji

import math
rad_sa = math.radians(sa)
cos_sa = math.cos(rad_sa)

tl = A**2 + B**2 - 2*A*B*cos_sa
print(tl**(1/2))

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

Solution (Python):
import math

p = math.pi
A, B, H, M = map(int, input().split())
t = H*60+M
ax, ay = A*math.sin((p*t)/360), A*math.cos((p*t)/360)
bx, by = B*math.sin(p*t/30), B*math.cos(p*t/30)
print(math.sqrt((ax-bx)**2+(ay-by)**2))

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

Solution (Python):
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn
    else:
        aug = 180.0
    
    if aug == 180.0:
        ans=a+b
        print(ans)
    
    else: 
        ans = (a**2.0) + (b**2.0) -( (2.0*a*b)*math.cos(math.radians(aug)) )
        print(math.sqrt(ans))



if __name__=='__main__':
    main()

Solution (Python):
import math

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

rad_h = (2 * math.pi / 12) * (h + m / 60)
rad_m = (2 * math.pi / 60) * m





theta = abs(rad_h - rad_m)




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

Solution (Python):
import numpy as np

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

long_rad = (H % 12) / 12. + M / (12. * 60)
short_rad = M / 60.

sub_rad = (np.abs(long_rad - short_rad))
if sub_rad > 1 / 2.:
    sub_rad = 1 - sub_rad

x = (A * np.cos(2 * np.pi * sub_rad))
y = (A * np.sin(2 * np.pi * sub_rad))
print(np.sqrt(y ** 2 + (B - x) ** 2))

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

x=30*h+0.5*m
k=abs(6*m-x)
k=cos(radians(k))

l=sqrt(a**2+b**2-2*a*b*k)
print(l)

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


d = abs(6*M - (0.5*M + 30*H))

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

Solution (Python):
import math

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

hour = h + (m / 60)

hour_dis = m / 60
hour_pos = (h + hour_dis) * 5
min_pos = m

dist = abs(hour_pos - min_pos)
if dist > 30:
  dist = 60 - dist

angle = (dist * 90) / 15

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

print(res)

Solution (Python):
import numpy as np
b,c,H,M=map(int, input().split())
h=H/12 * 360 + (360 / 12) * M/60

m=M/60 * 360

A=abs(m-h)

if A > 180:
    A = 360 - A

AR = A * np.pi / 180


ans2 = b*b+c*c - 2*b*c*np.cos(AR)

ans = np.sqrt(ans2)
print(ans)

Solution (Python):
import math


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

rad_ji = (H * 30 + M * 0.5)%360
rad_hun = M *6


if abs(rad_ji-rad_hun)==180:
    print(float(A+B))
else:
    if abs(rad_ji-rad_hun)>180:
        ans=math.sqrt(A**2+B**2 - 2*A*B*math.cos(math.radians(360-(rad_ji-rad_hun))))
    else:
        ans=math.sqrt(A**2+B**2 - 2*A*B*math.cos(math.radians(rad_ji-rad_hun)))
    print(ans)

Solution (Python):
import sys
import math

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

rad_B = M * 6
rad_A = H * 30 + M * 0.5

if rad_A < rad_B:
    rad_C = rad_A - rad_B
elif rad_A > rad_B:
    rad_C = rad_B - rad_A
elif rad_A == rad_B:
    rad_C = 0

rad_C = abs(rad_C)

if rad_C > 180:
    rad_C = 360 - rad_C



cos_C = math.cos(math.radians(rad_C))

C_2 = A ** 2 + B ** 2 - 2 * A * B * cos_C

C = math.sqrt(C_2)


print(C)

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

Solution (Python):
import math
a=list(map(int, input().split(' ')))
print(math.sqrt( abs( a[0]**2 + a[1]**2 - 2*a[0]*a[1]*math.cos(abs(2*math.pi*((a[2]*60+a[3])/720)-2*math.pi*(a[3]/60))))))

Solution (Python):
import math
A,B,H,M = map(int,input().split())
chousinnkakudo = M * 6
tannsinnkakudo = 0.5 * (H * 60 + M)
kakudo = chousinnkakudo - tannsinnkakudo
if kakudo < 0:
    kakudo -= 2 * kakudo
if kakudo > 180:
    kakudo = 360 - kakudo
if kakudo == 180:
    print(A+B)
    exit(0)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo))))

Solution (Python):

import math

a,b,c,d = map(float, input().split()) 

e=6*d
f=30*c+0.5*d

if e<f:
    kakudo=f-e
else:
    kakudo=e-f
    
if kakudo>180:
    kakudo=360-kakudo

a2=a*a
b2=b*b
i=math.cos(math.radians(kakudo))
j=2*a*b*i
print(math.sqrt(a2+b2-j))

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

w1 = 360 * ((h+m/60)/12)
w2 = 360 * (m/60)

s = min(abs(w1-w2), 360-abs(w1-w2))
rad = np.deg2rad(s)
d = np.cos(rad)

ans = (a**2 + b**2 - 2*a*b*d)**0.5

print(ans)

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

C = 0.5 * (60 * H + M) 
D = 6 * M 
E = math.radians(D - C) 

F = (A * A) + (B * B) - (2 * A * B * math.cos(E))

print(math.sqrt(F))

Solution (Python):
import math
A,B,H,M = map(int,input().split())
cos_theta = math.cos(math.radians(abs(30*H+0.5*M-6*M)))

ans = math.sqrt(A**2+B**2-2*A*B*cos_theta)
print('{:.20f}'.format(ans))

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

Solution (Python):
import math

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

arg=abs(((h*30)+(m*0.5))-m*6)


if arg>180:
    arg=360-arg

rad=math.radians(arg)

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

dim=dim**(1/2)

print(dim)

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

m_a = m * 6
h_a = h * 30
if m > 0:
    h_a = h_a + m * 0.5
print(math.sqrt(a ** 2 + b ** 2 - (2 * a * b * math.cos(math.radians(max(m_a, h_a) - min(m_a, h_a))))))

Solution (Python):
import math

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

dig_h = (((h * 60) + m) / (12 * 60)) * 360 
dig_m = (m / 60) * 360
if dig_h - dig_m < 0:
    ans = dig_m - dig_h
    if ans > 180:
        ans *= -1
        ans += 360
        
elif dig_h - dig_m > 180:
    ans = 360 - (dig_h - dig_m)
else:
    ans = dig_h - dig_m

if ans == 0:
    len = abs(a - b)
elif ans == 180:
    len = a + b
else :
    len = math.sqrt((a * a) + (b * b) - (2 * a * b * math.cos(math.radians(ans))))

print(float(len))

Solution (Python):
import math
A,B,H,M=input().split();
A=int(A);
B=int(B);
H=int(H);
M=int(M);
PI=math.pi
radA=2*PI*H/12+2*PI*M/(12*60);
radB=2*PI*M/60;
Ax,Ay=A*math.sin(radA),A*math.cos(radA);
Bx,By=B*math.sin(radB),B*math.cos(radB);
L=(Ax-Bx)*(Ax-Bx)+(Ay-By)*(Ay-By);
L=math.sqrt(abs(L));
print(L);

Solution (Python):
import math

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






hm = (h * 60 + m) / 2

mm = m * 6


A = max(hm, mm) - min(hm, mm)


AA = math.radians(A)


AAA = math.cos(AA)


c = (a**2) + (b**2) - (2 * a * b * AAA)


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

Solution (Python):
import math





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 = map(int,input().strip().split())
z = calcAngle(h, m)
p = math.cos((calcAngle(h, m)*math.pi)/180)
print((a**2+b**2-2*a*b*p)**0.5)

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



tansin = (H*60+M)*0.5
tyosin = M*6
kakudo = tansin - tyosin
ans = (A**2)+(B**2)-(2*A*B*math.cos(math.radians(kakudo)))
print(math.sqrt(ans))

Solution (Python):
import math

x = input().split()
a = float(x[0])
b = float(x[1])
h = float(x[2])
m = float(x[3])

degM = 6.0 * m
degH = (h * 60 + m) * 0.5
deg = abs(degM - degH)
if(deg > 180):
    deg = 360 - deg

if(deg == 180):
    print(a + b)
else:
    r = math.radians(deg)
    cosA = math.cos(r)
    p = math.sqrt(a * a + b * b - 2 * a * b * math.cos(r))
    print(round(p, 11))

Solution (Python):


import math







def main():
    A, B, H, M = map(int, input().split())
    ah = math.tau * ((H * 60 + M) / (12 * 60))
    am = math.tau * (M / 60)

    vh = ((H * 60 + M) / (12 * 60))
    vm = (M / 60)

    theta = (vh - vm) * math.tau
    d = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))

    print(d)

if __name__ == "__main__":
    main()

Solution (Python):
import math

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










angle_a = (H * 30) + (M * 0.5)
angle_b = M * 6




cos = 0
ret = 0

if(angle_a == angle_b):
  
  ret = abs(A - B)
else:
  if(angle_a > angle_b):
    cos = math.cos(math.radians(angle_a - angle_b))
    
  else:
    cos = math.cos(math.radians(angle_b - angle_a))
    
  
  ret = math.sqrt(A**2 + B**2 - 2 * A * B * cos)

print(ret)

Solution (Python):
import math

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

rad_h = 2 * math.pi * (h / 12 + m / (60 * 12))
rad_m = 2 * math.pi * (m / 60)

rad_hm = rad_h - rad_m

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

Solution (Python):
import math

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

a = float(a)
b = float(b)
h = float(h)
m = float(m)

hkaku = 360 * ((h + m / 60) / 12)
mkaku = 360 * (m / 60)

minkaku = min(hkaku, mkaku)
maxkaku = max(hkaku, mkaku)
t = maxkaku - minkaku
rad = t * (math.pi / 180)

if t == 90 or t == 270:
    res = math.sqrt(a * a + b * b)
elif t == 0:
    res = math.sqrt(a * a + b * b - 2 * a * b)
elif t == 180:
    res = a + b
else:
    res = math.sqrt(a * a + b * b - 2 * a * b * math.cos(rad))

print(res)

Solution (Python):
import math

li = list(map(int,input().split()))
b = li[0] / 1
c = li[1] / 1
h = li[2] / 1
m = li[3] / 1

ang1 = 6.0 * m
ang2 = (5.0 * h + m / 12.0) * 6.0
if ang1 > ang2:
	temp = ang1
	ang1 = ang2
	ang2 = temp
An = ang2 - ang1
An = An * math.pi
An = An / 180.0
ans = b*b + c*c - 2*b*c*math.cos(An)
ans = math.sqrt(ans)
print(ans)

Solution (Python):
import math

len_H, len_M, H, M = map(int, input().split())

theta_H = H * 30 + M * 0.5
theta_M = M * 6

diff = abs(theta_H - theta_M)
if diff > 180:
  diff = 360 - diff

a = len_H
b = len_M

theta = math.radians(diff)

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

print(math.sqrt(d))

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

import math
S=abs((H+M/60)*30-M*6)

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

print(ans)

Solution (Python):
from math import *

marume = 10

def main():
    a,b,h,m = map(int,input().split())
    long_degree = (h % 12) * 30 + 0.5 * m 
    short_degree = 6 * m 

    
    

    degree = abs(long_degree - short_degree) 
    t = round(tan(radians(degree)),marume) 
    s = round(sin(radians(degree)),marume) 
    c = round(cos(radians(degree)),marume)
    hen1 = s * max(a,b)
    hen2 = c * max(a,b) - min(a,b)
    answer = sqrt(hen1 ** 2 + hen2 ** 2)
    print(answer)





if __name__ == '__main__':
    main()

Solution (Python):
import math
import re
import copy

a,b,h,m = map(int,input().split())
h1 = a * math.cos(math.radians((h + m/60) * 30))
h2 = b * math.cos(math.radians(m * 6))
w1 = a * math.sin(math.radians((h + m/60) * 30))
w2 = b * math.sin(math.radians(m * 6))
h3 = abs(h1-h2)
w3 = abs(w1-w2)
l = math.sqrt((w3 ** 2) + (h3 ** 2))
print(l)

Solution (Python):
A, B, H, M = map(int, input().split())
from math import pi, cos, sin
a=2*pi*(H+M/60)/12
b=2*pi*M/60
c=abs(a-b)
ans2=A*A+B*B-2*A*B*cos(c)
print(ans2**0.5)

Solution (Python):
import math

n = input().split()

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


m = M/5
h = H + (M/60)

x = abs(h-m)
kakudo = x*30

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

Solution (Python):
def main():
    A, B, H, M = (int(i) for i in input().split())
    from math import radians, sqrt, cos
    rH = radians(0.5*(H*60+M))
    rM = radians(6*M)
    ans = sqrt(A**2 + B**2 - 2*A*B*cos(rM - rH))
    print(ans)


if __name__ == '__main__':
    main()

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

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

M_rad = M*360/60
AtoB_Cos = math.cos(math.radians(H_rad-M_rad)) 

solve = math.sqrt(A*A+B*B-2*A*B*AtoB_Cos)
print(solve)

Solution (Python):
import math

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

kaku = n[2] * 30 + n[3] * 0.5 - 6 *n[3]

if kaku >= 180:
    kaku = 360 - kaku

x = n[0]**2 + n[1]**2 - 2*n[0]*n[1] * math.cos(math.radians(kaku))
hen = math.sqrt(x)

print(hen)

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

if H <=6 and M<=30:
    a = H*30+30*M/60
    b = M*6
    kaku = max(a,b) - min(a,b)
elif H<=6 and M > 30:
    a = H*30+30*M/60
    b = (60-M)*6
    c = M*6
    kaku = min(a+b, c-a)
elif H>6 and M<=30:
    a = H*30+30*M/60
    b = M*6
    c = (12-H)*30-30*M/60
    kaku = min(c+b, a-b)
else:
    a = (12-H)*30-30*M/60
    b = (60-M)*6
    kaku = max(a,b) - min(a,b)

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

Solution (Python):
import math

a,b,h,m = map(int,input().split())
short_kakudo = 0.5 * (60*h + m)
long_kakudo = 6 * m
s = abs(short_kakudo - long_kakudo)

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

print(abs(c))

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

theta_h = (H % 12 + M/60)*30*pi/180
theta_m = (M % 60)*6*pi/180

Ax, Ay = A*sin(theta_h), A*cos(theta_h)
Bx, By = B*sin(theta_m), B*cos(theta_m)


d = ((Ax-Bx)**2 + (Ay-By)**2)**0.5
print(d)

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

Solution (Python):
import math 
import numpy as np
k = input().split(" ")
hour_length = float(k[0])
min_length = float(k[1])

hour_move = float(k[2])
min_move = float(k[3])

def pol2cart(rad, degree):
    
    
    
    radius = rad
    theta = math.degrees(degree)
    theta = theta * math.pi/180.0;

    x = radius * math.cos(theta)
    y = radius * math.sin(theta)
    return x,y
hour_moved_by_min = (min_move/60)
hour_degrees = (((hour_move+hour_moved_by_min)/12)*math.pi*2)
min_degrees = ((min_move/60)*math.pi*2)

xh,yh = pol2cart(hour_length,hour_degrees)
xm,ym = pol2cart(min_length,min_degrees)

dx = abs(xh-xm)
dy = abs(yh-ym)

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


print(hypo)

Solution (Python):
import math
from decimal import Decimal

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

sinrad1 = Decimal(str(math.sin(math.radians(6*M))))
cosrad1 = Decimal(str(math.cos(math.radians(6*M))))
sinrad2 = Decimal(str(math.sin(math.radians(30*H+0.5*M))))
cosrad2 = Decimal(str(math.cos(math.radians(30*H+0.5*M))))
ans = (float((B*sinrad1-A*sinrad2))**2 + float((B*cosrad1-A*cosrad2))**2)**0.5
print(ans)

Solution (Python):
import math

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

h=(h*60+m)*0.5
m=m*6
d=math.cos(math.radians(h-m))

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

print(c)

Solution (Python):
import math

a, b, h, m = map(float, input().split())
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) 

print(round(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angle))), 20))

Solution (Python):
import math

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

theta = abs(6 * M - (60 * H + M) / 2)
if theta > 180:
    theta = 360 - theta
theta = abs(math.radians(theta))
ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)
ans = math.sqrt(ans)
print(ans)

Solution (Python):
import math

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

cos = math.cos(math.radians((60*H - 11*M)/2))

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

print(result)

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

Solution (Python):
import math
def calcAngle(h,m):     
        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 = input().split()
for i in range(len(a)):
    a[i] = int(a[i])
print(math.sqrt(a[0]*a[0]+a[1]*a[1]-2*a[0]*a[1]*math.cos(math.radians(calcAngle(a[2],a[3])))))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
double_pi = math.pi * 2
hx = a * math.sin(double_pi * (h / 12 + (1 / 12 * m / 60)))
hy = a * math.cos(double_pi * (h / 12 + (1 / 12 * m / 60)))
mx = b * math.sin(double_pi * m / 60)
my = b * math.cos(double_pi * m / 60)
ans = (hx - mx) ** 2 + (hy - my) ** 2
ans **= 0.5
print(ans)

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

AngA = 30*H + 0.5*M
AngB = 6*M

AngC = AngA - AngB

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