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







hour_hand_angle = 30*H + M/2 
minute_hand_angle = 360*M/60


if hour_hand_angle == 180:
    angle_between_hour_and_minute = 180
elif hour_hand_angle > 180:
    if hour_hand_angle <= minute_hand_angle < 360:
        angle_between_hour_and_minute = minute_hand_angle - hour_hand_angle
    elif 0 <= minute_hand_angle <= hour_hand_angle - 180:
        angle_between_hour_and_minute = 360 - hour_hand_angle + minute_hand_angle
    else:
        angle_between_hour_and_minute = hour_hand_angle - minute_hand_angle
elif hour_hand_angle < 180:
    if 0 <= minute_hand_angle <= hour_hand_angle:
        angle_between_hour_and_minute = hour_hand_angle - minute_hand_angle
    elif hour_hand_angle < minute_hand_angle <= hour_hand_angle + 180:
        angle_between_hour_and_minute = minute_hand_angle - hour_hand_angle
    else:
        angle_between_hour_and_minute = 360 - minute_hand_angle + hour_hand_angle

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

Solution (Python):



import math
import cmath

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

def rate_to_arg(rate):
    return - 2 * math.pi * rate

short_rate = (H * 60 + M) / 720
long_rate = M / 60

short = 0 + A * 1j
short *= cmath.rect(1.0, rate_to_arg(short_rate))

long = 0 + B * 1j
long *= cmath.rect(1.0, rate_to_arg(long_rate))

print("{:.20f}".format(abs(long - short)))

Solution (Python):



import math
import cmath

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

def to_arg(rate):
    return - 2 * math.pi * rate

short_rate = (H * 60 + M) / 720
long_rate = M / 60

short = cmath.rect(A, math.pi / 2.0)
short *= cmath.rect(1.0, to_arg(short_rate))

long = cmath.rect(B, math.pi / 2.0)
long *= cmath.rect(1.0, to_arg(long_rate))

print("{:.20f}".format(abs(long - short)))

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

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

ta = h*2*pi/12 + m*2*pi/(12*60)
tb = m*2*pi/60

xa = a*cos(ta)
ya = a*sin(ta)
xb = b*cos(tb)
yb = b*sin(tb)

print(sqrt((xa-xb)**2 + (ya-yb)**2))

Solution (Python):
import math
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))

def main(a,b,h,m):
    hun = 2*math.pi * (m / 60)
    zi = 2*math.pi * ((60*h+m)/(12*60))
    kaku = abs(hun - zi)
    if kaku > math.pi : kaku = 2*math.pi - kaku
    rtn = math.sqrt(a**2+b**2-2*a*b*math.cos(kaku))
    return rtn

def resolve():
    a,b,h,m = mi()
    print(main(a,b,h,m))

if __name__ == "__main__":
    resolve()

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

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

Solution (Python):
import math

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

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



a_th = math.radians(a_deg)
b_th = math.radians(b_deg)
a_x, a_y = a * math.cos(a_th), a * math.sin(a_th)
b_x, b_y = b * math.cos(b_th), b * math.sin(b_th)
dis = math.sqrt((b_x - a_x) ** 2 + (b_y - a_y) ** 2)
print(dis)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
th = (60 * h + m) * math.pi / 360
tm = m * math.pi / 30
dx = a * math.cos(th) - b * math.cos(tm)
dy = a * math.sin(th) - b * math.sin(tm)
print(math.sqrt(dx * dx + dy * dy))

Solution (Python):
from cmath import exp
from math import radians


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

    
    
    h_hand = A * exp(radians((H % 12) * 30 + float(M) / 60.0 * 30.0) * 1j)
    m_hand = B * exp(radians(M / 60 * 360) * 1j)

    ans = abs(m_hand - h_hand)
    print(ans)


if __name__ == "__main__":
    main()

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

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

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

time = 60 * h + m
wa = pi / 360.0; theta_a = wa * time
wb = pi / 30.0; theta_b = (wb * time) % (2 * pi)
diff = abs(theta_a - theta_b)

ans = sqrt(a**2 + b**2 - 2*a*b*cos(diff))
print (ans)

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

A,B,H,M=map(int,input().split())
t1,t2=pi*(H+M/60)/6,pi*M/30
print(sqrt(A*A+B*B-2*A*B*cos(t1-t2)))

Solution (Python):
import math

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

Solution (Python):
import math

a,b,h,m=map(int,input().split())
asita= 2*math.pi*(h/12 + m/(12*60))
bsita= 2*math.pi*m/60
sita= min(abs(asita-bsita), 2*math.pi-abs(asita-bsita))

ans=(a**2 + b**2 - 2*a*b*math.cos(sita))**0.5
print(ans)

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

PI = math.acos(-1)
th = (H / 12 + (M / 60) * (1 / 12)) * 2 * PI
tm = (M / 60) * 2 * PI

xh = A * math.cos(th)
yh = A * math.sin(th)
xm = B * math.cos(tm)
ym = B * math.sin(tm)
dx = xh - xm
dy = yh - ym
ans = (dx * dx + dy * dy) ** (1 / 2)
print(ans)

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

Solution (Python):
import math
a, b, h, m = [int(_) for _ in input().split()]
ah = 30 * (h + m / 60)
am = 6 * m
print((a**2 + b**2 - 2 * a * b * math.cos(math.pi * (ah - am) / 180))**0.5)

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

t=abs((h*30+m*0.5)-m*6)
if t>180:
  t=360-t
else:
  pass

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

print(ans)

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

A,B,H,M=map(int,input().split())
t1,t2=pi*(H+M/60)/6,pi*M/30
print(sqrt((A*cos(t1)-B*cos(t2))**2+(A*sin(t1)-B*sin(t2))**2))

Solution (Python):
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    A, B, H, M = read_ints()
    angle1 = 2*math.pi*(H+M/60)/12
    angle2 = 2*math.pi*M/60
    c = abs(angle1-angle2)
    return math.sqrt(A*A+B*B-2*A*B*math.cos(c))


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

Solution (Python):

import sys
from math import sin, cos, radians

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


A, B, H, M = lr()
d1 = radians(30 * H + 30 * M / 60)
d2 = radians(360 * M / 60)
x1, y1 = A * cos(d1), A * sin(d1)
x2, y2 = B * cos(d2), B * sin(d2)
c1 = complex(x1, y1)
c2 = complex(x2, y2)
answer = abs(c1-c2)
print(answer)

Solution (Python):
import math

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

start = 30*h
d = min(abs(start - 5.5 * m),360-abs(start - 5.5 * m))


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

Solution (Python):
import math

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

deg_h = h*30 + 30*(m/60)
deg_m = m*6

rad_h = deg_h*(math.pi/180)
rad_m = deg_m*(math.pi/180)

h_x = a*math.sin(rad_h)
h_y = a*math.cos(rad_h)

m_x = b*math.sin(rad_m)
m_y = b*math.cos(rad_m)

len = math.sqrt(pow((h_x-m_x),2)+pow((h_y-m_y),2))

print(len)

Solution (Python):
import math

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

deg_h = h*30 + 30*(m/60)
deg_m = m*6

deg_sub = abs(deg_h - deg_m)
rad_sub = deg_sub*(math.pi/180)

len = math.sqrt(a*a + b*b - 2*a*b*math.cos(rad_sub))

print(len)

Solution (Python):


import math


line = input().split(" ")
A = int(line[0])
B = int(line[1])
H = int(line[2])
M = int(line[3])

ans = 0


ang_a = H * 5 + M/12

ang_b = M

if ang_a == ang_b:
    ans = A - B

else:
    diff = abs(ang_a-ang_b)
    theta = (diff / 60) * 360
    ans_pow = A**2 + B**2 - 2 * A * B * math.cos(math.radians(theta))
    ans = ans_pow**0.5

print(ans)

Solution (Python):
import math

class Position:
    def __init__(self, r, sita):
        self.x = r * math.cos(sita)
        self.y = r * math.sin(sita)

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


def solve(a, b, h, m):
    t = 60 * h + m
    Rh, Rm = math.pi / 2 - (t % 720) / 360 * math.pi, math.pi / 2 - (t % 60) / 30 * math.pi
    H = Position(a, Rh)
    M = Position(b, Rm)
    ans = (abs(H.x - M.x) ** 2 + abs(H.y - M.y) ** 2) ** (1 / 2)
    return ans


if __name__ == '__main__':
    main()

Solution (Python):
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):
from math import pi, cos, sqrt

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

angleL = 2 * pi * (H*60+M) / (12*60)
angleS = 2 * pi * M / 60
angle = max(angleL, angleS) - min(angleL, angleS)


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

Solution (Python):
import math

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

angleL = 2 * math.pi * (H*60+M) / (12*60)
angleS = 2 * math.pi * M / 60
angle = max(angleL, angleS) - min(angleL, angleS)


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

Solution (Python):
import math
a,b,h,m =map(int,input().split())
 
x =30*h+(m*0.5)%360
 
y=m*6
sa =abs(x-y)
if a>b:
    c=b
    b=a
    a=c
t =(math.sin(math.radians(sa)))*b
 
f=math.sqrt(b**2-t**2)
if 90 <= sa <= 270:
    a =-a
print(math.sqrt((f-a)**2+t**2))

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

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

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

print(c)

Solution (Python):
import math

a,b,h,m = list(map(float,input().split()))
theta   = 2*math.pi*( (h+m/60)/12 - m/60 )
  
l = ( a**2+b**2-2*a*b*math.cos(theta) )**0.5
print(l)

Solution (Python):
import numpy as np

a, b, h, m = map(int, input().split())
thetaH = np.deg2rad(360/12*h + 360/(12*60)*m)
thetaM = np.deg2rad(360/60*m)
thetaDiff = thetaH - thetaM

x0 = a
y0 = 0

x1 = b*np.cos(thetaDiff)
y1 = b*np.sin(thetaDiff)

ans = np.sqrt((x0-x1)**2 + (y0-y1)**2)
print(ans)

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

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

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

x1 = A * cos(2 * pi * (H + M / 60) / 12)
y1 = A * sin(2 * pi * (H + M / 60) / 12)
x2 = B * cos(2 * pi * M / 60)
y2 = B * sin(2 * pi * M / 60)

print(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)))

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

Solution (Python):
from math import *
 
a,b,h,m=map(int,input().split())
print((a*a+b*b-2*a*b*cos((m*11/360-h/6)*pi))**.5)

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


print(math.sqrt((a**2+b**2) - (2*a*b*math.cos( (abs(e-r)*math.pi/180)))))

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

Solution (Python):
import math
A, B, H, M = [int(i) for i in input().split()]
H = H*30 + M*0.5
M *= 6
print(math.sqrt(A**2 + B**2 - (2*A*B) * math.cos(math.radians(H-M if H > M else M-H))))

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

Solution (Python):
def c(l, t):
    from math import cos, sin
    return l * cos(t), l * sin(t)


def d(a, b, c, d):
    return ((a - c)**2 + (b - d)**2)**0.5


def solve(string):
    from math import pi
    a, b, h, m = map(int, string.split())
    return str(d(*c(a, (h + m / 60) / 6 * pi), *c(b, m / 30 * pi)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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


def coord(l, t):
    return l * cos(t), l * sin(t)


def d(a, b, c, d):
    return ((a - c)**2 + (b - d)**2)**0.5


def solve(string):
    a, b, h, m = map(int, string.split())
    return str(d(*coord(a, (h + m / 60) / 6 * pi), *coord(b, m / 30 * pi)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
import math

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

theta = (h / 12 + m / 60 / 12) * 2 * math.pi
a_x = a * math.sin(theta)
a_y = a * math.cos(theta)

phi = m / 60 * 2 * math.pi
b_x = b * math.sin(phi)
b_y = b * math.cos(phi)

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

print(distance)

Solution (Python):
from decimal import Decimal
import math
a , b, h , m = map(int , input().split())
angh = (h/12)*360 + (m/60)*30
angm = (m/60)*360

ang = abs(angh-angm)




val = a*a + b*b - 2*a*b*math.cos(math.radians(ang))
print(val**0.5)

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

a,b,h,m = map(int, input().split())
th_m = m*2*pi/60
th_h = (60*h + m)*2*pi/720

mx = math.cos(th_m)*b
my = math.sin(th_m)*b
hx = math.cos(th_h)*a
hy = math.sin(th_h)*a

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

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

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

x1 = A * cos(2 * pi * (H + M / 60) / 12)
y1 = A * sin(2 * pi * (H + M / 60) / 12)
x2 = B * cos(2 * pi * M / 60)
y2 = B * sin(2 * pi * M / 60)

print(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)))

Solution (Python):
import math
from decimal import *

nums = [int(i) for i in input().split()]
a = nums[0]
b = nums[1]
h = nums[2]
m = nums[3]
l = 0

getcontext().prec = 11
angleh = Decimal(2 * math.pi * (h / 12.0 + m / 60.0 / 12.0))
anglem = Decimal(2 * math.pi * m / 60.0)


angle = anglem - angleh
getcontext().prec = 28
l = a ** 2 + b ** 2 - 2 * a * b * Decimal(math.cos(angle))
print(Decimal(l).sqrt())

Solution (Python):
import math


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

minutes = h * 60 + m

min_needle_angle = minutes * 6
hour_needle_angle = minutes * 0.5








angle = abs(min_needle_angle - hour_needle_angle)






angle = min(angle, 360 - angle) 










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

print((c_nijou)**0.5)

Solution (Python):
import math

a,b,h,m=map(int,input().split())
x = abs(math.pi*(60*h-11*m)/360)
ans = ( a**2 + b**2 - math.cos(x)*2*a*b ) **0.5
print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,h,w = inpl()
x,y = 30*(h+(w/60)), 6*w
C = min(abs(x-y),360-abs(x-y))
tmp = a**2 + b**2 - 2*a*b*math.cos(math.radians(C))
print(math.sqrt(tmp))

Solution (Python):
import sys
from cmath import pi, rect

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

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

H += M / 60

t1 = 2 * pi * H / 12
t2 = 2 * pi * H

z1 = rect(A, t1)
z2 = rect(B, t2)

print(abs(z1 - z2))

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

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]

A,B,H,M = inputlist()
from math import pi,cos
def rad_hour(H,M):
    return ((H+(M/60))*pi)/6
def rad_min(M):
    return M*pi/30

rad_h = rad_hour(H,M)
rad_m = rad_min(M)
d_rad = max(rad_h,rad_m) - min(rad_h,rad_m)
theta = min(2*pi-d_rad,d_rad)

l2 = A**2 + B**2 - 2*A*B*cos(theta)
print(l2**(1/2))

Solution (Python):
import sys
import numpy as np

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

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

H += M / 60

t1 = 2 * np.pi * H / 12
t2 = 2 * np.pi * H

z1 = A * np.exp(t1 * 1j)
z2 = B * np.exp(t2 * 1j)

print(abs(z1 - z2))

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

from math import cos,radians


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

print((a**2 + b**2 - 2*a*b*cos(radians(theta)))**0.5)

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

from math import cos,radians


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

print((a**2 + b**2 - 2*a*b*cos(radians(theta)))**0.5)

Solution (Python):
import math

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

Solution (Python):
from math import *

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

a_k=(h+m/60)*30
b_k=m*6
k=abs(a_k-b_k)

if k==0:
  print(abs(a-b))
else:
  x=a**2+b**2-2*a*b*cos(radians(k))
  print(x**0.5)

Solution (Python):
import math

a,b,h,m = (int(x) for x in input().split())
rada = 6*m
radb = (60*h+m)/2

rad = rada-radb
c2 = a*a+b*b-2*a*b*math.cos(math.radians(rad))

print("%.12f" % math.sqrt(c2))

Solution (Python):
import math

if __name__ == '__main__':
    A, B, H, M = map(int, input().split())
    
    minute_passed = float(H) * 60.0 + float(M)
    l = (0.5 * (math.pi / 180.0) * minute_passed) % (2.0 * math.pi)
    s = (6.0 * (math.pi / 180.0) * minute_passed) % (2.0 * math.pi)
    deg = abs(s - l)
    print(format(math.sqrt(B ** 2.0 + A ** 2.0 - 2.0 * A * B * math.cos(deg)), '.20f'))

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

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

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)
 
result_root = A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudosa))
 
print(math.sqrt(result_root))

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

rad = radians(abs((h*60+m)/720 - m/60)*360)

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

print(c)

Solution (Python):
import sys 
import math


a, b, h, m = map(int,input().split())
rad = math.pi*2*((h/12.0) + (m/60.0)/12.0 - (m/60.0))
ans = math.sqrt(a*a + b*b - (2*a*b*math.cos(rad)))
print(ans)

Solution (Python):
a,b,h,m=map(int,input().split());from math import*;print((a*a+b*b-2*a*b*cos((m*11/360-h/6)*pi))**.5)

Solution (Python):



import math

A, B, H, M = map(int, input().split())
angle_hour = (H + M / 60) * 30
angle_min = 6 * M
angle = min(abs(angle_hour - angle_min), 360 - abs(angle_hour - angle_min))
ans = math.sqrt(pow(A, 2) + pow(B, 2) - 2 * A * B * math.cos(math.radians(angle)))
print(ans)

Solution (Python):
import math

a,b,h,m=map(int,input().split())
seconds=h*60+m
kaku=seconds*5.5
k_kaku=kaku%360
if k_kaku>180:
  g_kaku=360-k_kaku
else :
  g_kaku=k_kaku
p_kaku=math.radians(g_kaku)
cos=math.cos(p_kaku)
l=a**2+b**2-2*a*b*cos
len=math.sqrt(l)
print(len)

Solution (Python):

import math
def resolve():
    A, B, H, M = map(int, input().split())
    
    deg_H = 360/12
    
    deg_M = 360/60

    hr = deg_H*H + (deg_H/60)*M
    mr = deg_M*M
    deg = abs(hr-mr)
    if deg>180:
        deg = 360- deg

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

if __name__ == "__main__":
    resolve()

Solution (Python):
import math

a,b,h,m=map(int,input().split())
seconds=h*60+m
kaku=seconds*5.5
k_kaku=kaku%360
if k_kaku>180:
  g_kaku=360-k_kaku
else :
  g_kaku=k_kaku
p_kaku=math.radians(g_kaku)
cos=math.cos(p_kaku)
l=a**2+b**2-2*a*b*cos
len=math.sqrt(l)
print(len)

Solution (Python):

import math as m

A, B, H, M = map(int, input().split())
radianH = m.radians(H * 30 + M * 30 / 60)
radianM = m.radians(6 * M)

hour = A * complex(m.cos(radianH), m.sin(radianH))
minute = B * complex(m.cos(radianM), m.sin(radianM))

ans = abs(hour - minute)

print(ans)

Solution (Python):
import math


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


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


if M != 0:
    deg_M = M / 60 * 360
else:
    deg_M = 360


t = abs(deg_H - deg_M)


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

Solution (Python):
import math


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

min = 60 * H + M


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


if M != 0:
    deg_M = M / 60 * 360
else:
    deg_M = 360


t = abs(deg_H - deg_M)


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

Solution (Python):
import math


class P:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __sub__(self, q):
        return P(self.x-q.x, self.y-q.y)

    def length(self):
        return (self.x**2+self.y**2)**.5


a, b, h, m = map(int, input().split())
minutes = 60*h+m
h_deg = minutes/2 % 360
m_deg = minutes*6 % 360
v1 = P(a*math.cos(math.radians(h_deg)), a*math.sin(math.radians(h_deg)))
v2 = P(b*math.cos(math.radians(m_deg)), b*math.sin(math.radians(m_deg)))
print((v1-v2).length())

Solution (Python):
import math
a, b, h, m = map(int, input().split())
minutes = 60*h+m
h_deg = minutes/2 % 360
m_deg = minutes*6 % 360
deg = h_deg-m_deg
print((a**2+b**2-2*a*b*math.cos(math.radians(deg)))**.5)

Solution (Python):
import math
import numpy as np
a,b,h,m = list(map(int, input().split()))
s1 = h * 30
s2 = m * 6
s1 = s1 + 30 * m / 60
s3 = abs(s2-s1)
if(s3 > 180):
  s3 = 360 - s3

e = (a * a) + (b * b) - (2 * a * b * np.cos(math.pi * s3/180))
ans=e ** 0.5
print('{:.9f}'.format(ans))

Solution (Python):
import math
from decimal import Decimal

def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

def main():
    A, B, H, M = map(int, input().split())
    deg_H = (360 // 12) * H + 0.5 * M
    deg_M = (360 // 60) * M
    
    x_A = A * Decimal(math.sin(math.radians(deg_H)))
    y_A = A * Decimal(math.cos(math.radians(deg_H)))
    x_B = B * Decimal(math.sin(math.radians(deg_M)))
    y_B = B * Decimal(math.cos(math.radians(deg_M)))
    
    ans = float((Decimal(x_A) - Decimal(x_B)) ** 2 + (Decimal(y_A) - Decimal(y_B)) ** 2) ** 0.5
    print(ans)




if __name__ == "__main__":
    main()

Solution (Python):


import math
import sys
from collections import defaultdict
input = sys.stdin.readline

a,b,h,m = map(int,input().split())
dig = (h * 60 + m )*5.5 %360
print((a**2+b**2-2*a*b*math.cos(math.radians(dig)))**(1/2))

Solution (Python):
def main():
    import sys
    import math
    a, b, h, m = tuple(map(int, sys.stdin.readline().split()))
    
    C = math.radians(abs(360*h/12 + 30*m/60 - 360*m/60))
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(C)))

if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,h,w = inpl()
x,y = 30*(h+(w/60)), 6*w
C = min(abs(x-y),360-abs(x-y))

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

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


H = H/12 * 60
H = H + (1/12 * M)
shita = math.radians(abs(H-M)*6)
if shita > math.pi:
    shita = 2*math.pi - shita
cos_shita = math.cos(shita)
c_zizyou = A**2 + B**2 - 2 * A * B * cos_shita
print(math.sqrt(c_zizyou))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
angle = math.pi*2*(h/12 + m/(12*60) - m/60)
ans = (a**2 + b**2 - 2*a*b*math.cos(angle))**0.5

print(ans)

Solution (Python):
import math

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

agh = (h*360)/12 + (m*360)/(12*60)
agm = (m*360)/60

diff = abs(agh - agm)
diff = min(diff, 360 - diff) 

if h == 5*m: 
    ans = abs(a - b)
if diff == 180: 
    ans = a + b
else:
    ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(diff)))**0.5

print(ans)

Solution (Python):
import math
A, B, H, M = list(map(int, input().split()))
omega_H = 2 * math.pi / (12*60)
omega_M = 2 * math.pi / (60)
total_M = H*60+M
Ax = A*math.sin(omega_H*total_M)
Ay = A*math.cos(omega_H*total_M)
Bx = B*math.sin(omega_M*total_M)
By = B*math.cos(omega_M*total_M)
ans = math.sqrt((Ax-Bx)**2 + (Ay-By)**2)
print(ans)

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

theta_h = H / 12 * 360 + M / 60 * 30
theta_m = M / 60 * 360
theta = abs(theta_h - theta_m)
theta = min(360 - theta, theta)

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

print(sqrt(ans))

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

Solution (Python):
import math
import numpy as np

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

h_deg = (h*60 + m) * (math.pi*2 / 720)
m_deg = m * (math.pi*2 / 60)

a_x = a * math.cos(h_deg)
a_y = a * math.sin(h_deg)
b_x = b * math.cos(m_deg)
b_y = b * math.sin(m_deg)

x_vec = np.array([a_x-b_x,a_y-b_y])

print(np.linalg.norm(x_vec, ord=2))

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

d = abs(360//12*(h+m/60) - 360//60*m)
print((a**2+b**2-2*a*b*math.cos(math.radians(d)))**0.5)

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

d = abs(30*(h+m/60) - 6*m)
print((a**2+b**2-2*a*b*math.cos(math.radians(d)))**0.5)

Solution (Python):


import sys,math
(A,B,H,M) = map(int,input().split())
print(A,B,H,M,file=sys.stderr)


rad1 = H*(30) + M*(0.5)
rad2 = M*(6)


rad = abs(rad1 - rad2)
ans = 0


'''
if rad == 180:
    ans = A+B
else:
    
    ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(rad)))
'''
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(rad)))

print(rad1,rad2,rad,ans,file=sys.stderr)
print(ans)

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

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

Solution (Python):
import math

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

h = 360 / (12 * 60)
m = 360 / 60

deg = abs(360 - abs(h * (H * 60 + M) - m * M))

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from math import sqrt 
from math import cos
from math import pi
def main():
    A, B, H, M = map(int, readline().split())
    h = (H/6)*pi+(((30/60)*M)/360)*2*pi
    m = (M/30)*pi
    theta = min(2*pi-abs(m-h), abs(m-h))
    print(sqrt(A**2+B**2-2*A*B*cos(theta)))
if __name__ == '__main__':
    main()

Solution (Python):
import math
A,B,H,M =map(int,input().split())
a = 30*H + 30*M/60
b = 6*M
s = (b-a)/180*math.pi
C =math.sqrt(A**2 + B**2 - 2*A*B*math.cos(s))
print(C)

Solution (Python):
import math

A, B, H, M = list(map(int, input().split()))
rad = math.pi * 2 * (H/12 + M/60/12 - M/60)

a = A**2 + B**2 - 2*A*B*math.cos(rad)
print(a**0.5)

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

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

Solution (Python):
from math import cos, radians


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


h = 30 * H + 0.5 * M
m = 6 * M
if abs(m - h) >= 180:
    hm = radians(360 - abs(m - h))
else:
    hm = radians(abs(m - h))

C = (A ** 2 + B ** 2 - 2 * A * B * cos(hm)) ** 0.5

print(C)

Solution (Python):


import sys,math
(A,B,H,M) = map(int,input().split())
print(A,B,H,M,file=sys.stderr)


rad1 = H*(30) + M*(0.5)
rad2 = M*(6)


rad = abs(rad1 - rad2)
ans = 0


if rad == 180:
    ans = A+B
else:
    
    ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(rad)))

print(rad1,rad2,rad,ans,file=sys.stderr)
print(ans)

Solution (Python):
import math

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

h_deg = (60*h + m) * (math.pi*2 / 720)
m_deg = m * (math.pi*2 / 60)

cos = math.cos(abs(h_deg - m_deg))
 
print(math.sqrt((a*a) + (b*b) - (2*a*b*cos)))

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
time = m + h*60
angle = time * 0.5 - time * 6
radian = math.radians(angle)
rad = math.cos(radian)
ans = a**2 + b**2 - 2*a*b*rad
print(math.sqrt(ans))

Solution (Python):
import math
A,B,H,M=map(int,input().split())
cen=(60*H+M)/2-6*M
cen_cos=math.cos(math.radians(cen))

print((A**2+B**2-2*cen_cos*A*B)**0.5)

Solution (Python):
from math import pi, cos

a, b, h, m = map(int, input().split())
x = pi/6
y = pi/30
z = x/60
C = abs(x*h+z*m - y*m)
print(f"{(a**2 + b**2 - 2 * a*b * cos(C))**2**-1:.20f}")

Solution (Python):
import cmath
a,b,h,m = map(int, input().split())
print(abs(a-b*cmath.rect(1,(h/12-m*11/720)*2*cmath.pi)))

Solution (Python):
import math
num = input().split()
A = int(num[0])
B = int(num[1])
H = int(num[2])
M = int(num[3])
M1 = 6*M
H1 = 30*H + 30*M/60
c = min((360-(max(H1, M1)-min(H1, M1))), (max(H1, M1)-min(H1, M1)))
C = A**2 + B**2 - (2 * A * B * (math.cos(math.radians(c))))
print(math.sqrt(C))