AtCoder Beginner Contest 168 - : (Colon)

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-----
3 4 9 0

-----Sample Output-----
5.00000000000000000000

The two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.

Source: atcoder | Difficulty: EASY


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


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

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

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

def MF():
	return map(float, input().split())

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

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	(A, B, H, M) = MI()
	pai = math.pi
	h = H / 12 + M / 720
	m = M / 60
	angle = abs(h - m)
	if angle > 0.5:
		angle = 1 - angle
	res = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(360 * angle))
	print(math.sqrt(res))

def __starting_point():
	main()
__starting_point()


from math import pi, cos, sqrt, radians

def main():
	(A, B, H, M) = map(int, input().split())
	HTheta = H / 12 * 360 + 1 / 12 * (M / 60) * 360
	MTheta = M / 60 * 360
	Theta = abs(HTheta - MTheta)
	if Theta == 180:
		print(A + B)
		return
	print(sqrt(A * A + B * B - 2 * A * B * cos(radians(Theta))))
main()


from cmath import *
(A, B, H, M) = map(int, input().split())
print(abs(rect(A, pi * (H + M / 60) / 6) - rect(B, pi * M / 30)))


import math
(a, b, H, M) = map(int, input().split())
ans = math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(math.radians(abs(30 * H - 11 * M / 2))))
print(ans)


from math import *
(a, b, h, m) = map(int, input().split())
deg1 = 30 * h + 0.5 * m
deg2 = 6 * m
c = a ** 2 + b ** 2 - 2 * a * b * cos(radians(deg1 - deg2))
print(c ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.pi * (60 * H - 11 * M) / 360))
print(ans)


from math import cos, pi
(A, B, H, M) = map(int, input().split())
print((A ** 2 + B ** 2 - 2 * A * B * cos(abs((60 * H + M) * pi / 360 - M * pi / 30))) ** 0.5)


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


import math
(A, B, H, M) = list(map(int, input().split()))
rad = (H / 12 - M * 11 / 720) * 2 * math.pi
ans = (A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)) ** (1 / 2)
print(ans)


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


import math
(A, B, H, M) = map(int, input().split())
M_deg = M / 60 * 360
H_deg = H / 12 * 360 + M_deg / 12
deg = min(abs(H_deg - M_deg), abs(M_deg - H_deg))
rad = math.radians(deg)
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))
print(ans)


import math

def i_input():
	return int(input())

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

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

def i_row(N):
	return [int(input()) for _ in range(N)]

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

def degCal(hour, minite):
	ansDeg = 0
	convHour = hour + minite / 60
	angA = 2 * math.pi / 12 * convHour
	angB = 2 * math.pi * convHour
	ansDeg = abs(angA - angB)
	return ansDeg

def lenCal(deg, lenA, lenB):
	ansLen = math.sqrt(lenA ** 2 + lenB ** 2 - 2 * lenA * lenB * math.cos(deg))
	return ansLen
(a, b, h, m) = i_map()
angle = degCal(h, m)
ans = lenCal(angle, a, b)
print(ans)


(A, B, H, M) = map(int, input().split())
import math
c = float(math.pi * 2 * (H / 12 + M / 720 - M / 60))
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(c)) ** (1 / 2))


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


import math
(A, B, H, M) = map(int, input().split())
h = 30 * H + 0.5 * M
m = 6 * M
C = abs(h - m)
X = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(C)))
print(X)


from math import *

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
		h += 1
		if h > 12:
			h = h - 12
	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) = [int(i) for i in input().split()]
theta = calcAngle(h, m) * pi / 180
ans = (a ** 2 + b ** 2 - 2 * a * b * cos(theta)) ** (1 / 2)
print('{:.15f}'.format(ans))


import math
(a, b, h, m) = map(float, input().split())
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians((h * 60 + m) * 11 % 720 / 2))))


(A, B, H, M) = map(int, input().split())
import math
H_angle = M * math.pi / 30
M_angle = (60 * H + M) * math.pi / 360
(H_x, H_y) = (A * math.cos(H_angle), A * math.sin(H_angle))
(M_x, M_y) = (B * math.cos(M_angle), B * math.sin(M_angle))
d = math.sqrt((H_x - M_x) ** 2 + (H_y - M_y) ** 2)
print(d)


import math
(A, B, H, M) = map(int, input().split())
x = 2 * math.pi * abs(H / 12 + M / 60 / 12 - M / 60)
ans = pow(A * A + B * B - 2 * A * B * math.cos(x), 1 / 2)
print(ans)


import math as mt
(a, b, h, m) = list(map(int, input().split()))
print(mt.sqrt(a ** 2 + b ** 2 - 2 * a * b * mt.cos(2 * mt.pi * (1 / 12 * (h + m / 60) - m / 60))))


import math
(a, b, h, m) = list(map(int, input().split()))
deg_m = m / 60 * 360
deg_h = (60 * h + m) / 720 * 360
deg = abs(deg_h - deg_m)
deg = math.radians(min(360 - deg, deg))
x2 = b ** 2 + a ** 2 - 2 * b * a * math.cos(deg)
print(x2 ** 0.5)


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


import math
(A, B, H, M) = map(int, input().split())
rad = abs(math.pi / 6 * (H + M / 60) - math.pi / 30 * M)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)) ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
a2 = A * A + B * B - 2 * A * B * math.cos(math.pi * 2 * (H / 12 + M / 720 - M / 60))
print(math.sqrt(a2))


import math as m
(A, B, H, M) = list(map(int, input().split()))
print(m.sqrt(A ** 2 + B ** 2 - 2 * A * B * m.cos(3.1415926535 / 180 * (30 * H - 11 * M / 2))))


import math
(a, b, h, m) = map(int, input().split())
theta_h = 2 * math.pi * (h + m / 60) / 12
theta_m = 2 * math.pi * m / 60
d_theta = abs(theta_h - theta_m)
answer = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(d_theta))
print(answer)


(a, b, h, m) = map(int, input().split())
t = h * 60 + m
c = 5.5 * t % 360
import math
x = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(c))
print(x ** 0.5)


import math
(a, b, h, m) = list(map(int, input().split()))
h_deg = (60 * h + m) * (360 / (60 * 12))
m_deg = m * (360 / 60)
deg = abs(h_deg - m_deg)
rad = math.radians(deg)
c = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(math.sqrt(c))


import math
(A, B, H, M) = list(map(int, input().split()))
print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(11 / 2 * (60 * H + M)))))


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


import math
(A, B, H, M) = map(int, input().split())
t = (11 * M / 360 - H / 6) * math.pi
p = A ** 2 + B ** 2 - 2 * A * B * math.cos(t)
print(p ** (1 / 2))


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


import math
(A, B, H, M) = list(map(int, input().split()))
Hx = math.cos((H / 12 + 1 / 12 * (M / 60)) * 2 * math.pi) * A
Mx = math.cos(M / 60 * 2 * math.pi) * B
Hy = math.sin((H / 12 + 1 / 12 * (M / 60)) * 2 * math.pi) * A
My = math.sin(M / 60 * 2 * math.pi) * B
print(math.sqrt((Hx - Mx) * (Hx - Mx) + (Hy - My) * (Hy - My)))


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


import math
(A, B, H, M) = list(map(int, input().split()))
wa = math.pi * 2 / 60 / 12
wb = math.pi * 2 / 60
theta = (wb - wa) * (H * 60 + M) % (2 * math.pi)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)) ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
s = float(max(6 * M, 30 * H + 1 / 2 * M) - min(6 * M, 30 * H + 1 / 2 * M)) / 180 * math.pi
print(float(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(s))))


import math
(a, b, h, m) = map(int, input().split())
q = abs((h + m / 60) / 12 - m / 60) * 360
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(q))))


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)


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


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


import math
(a, b, c, d) = map(int, input().split())
angle = d * 6 % 360 - (c * 30 + d * 0.5) % 360
l = a * a + b * b - 2 * a * b * math.cos(math.radians(angle))
print(l ** 0.5)


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


import math
(A, B, H, M) = map(int, input().split())
Btheta = M * math.pi / 30
Bx = B * math.cos(Btheta)
By = B * math.sin(Btheta)
Atheta = (60 * H + M) / 360 * math.pi
Ax = A * math.cos(Atheta)
Ay = A * math.sin(Atheta)
print(((Ax - Bx) ** 2 + (Ay - By) ** 2) ** (1 / 2))


(a, b, h, m) = map(float, input().split())
import math
p = math.pi
deg = math.radians(30 * h - 5.5 * m)
print((a ** 2 + b ** 2 - 2 * a * b * math.cos(deg)) ** 0.5)


import math
from decimal import Decimal
(hour_len, minute_len, hour, minute) = list(map(int, input().split()))
degree_hm = abs((hour * 60 + minute) * 0.5 - minute * 6)
rad_hm = math.radians(degree_hm)
cos_hm = math.cos(rad_hm)
a_double = hour_len ** 2 + minute_len ** 2 - 2 * hour_len * minute_len * cos_hm
ans = math.sqrt(a_double)
print(f'{ans:.20f}')


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


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


import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf, pi, cos
from copy import deepcopy
import numpy as np
import scipy as sp
INF = inf
MOD = 1000000007
(a, b, h, m) = [int(i) for i in input().split()]
tmp = 0
res = 0
theta = 2 * pi * (h / 12.0 + m / 720.0 - m / 60.0)
res = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theta))
print(res)


import math
(a, b, c, d) = map(int, input().split())
s = c / 12 + d / 720 - d / 60
s = abs(s) * 2 * math.pi
e = a ** 2 + b ** 2 - 2 * a * b * math.cos(s)
print(e ** 0.5)


import math
(a, b, h, m) = map(int, input().split())
k = h * 30 + m / 12 * 6 - m * 6
print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.pi / 180 * k)))


import math
(a, b, h, m) = list(map(int, input().split()))
ang = abs(h * 30 - m * 11 / 2)
angle = min(ang, 360 - ang)
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(angle)))
print(c)


import math
(a, b, h, m) = map(int, input().split())
deg = abs(30 * h - 5.5 * m)
print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(deg * math.pi / 180)))


from math import *
(a, b, h, m) = map(int, input().split())
d = radians(fabs(11 * m / 2 - 30 * h))
print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(d)))


from math import cos, pi
(a, b, h, m) = map(int, input().split())
d = 5.5 * (h * 60 + m)
print((a * a + b * b - 2 * a * b * cos(d / 180 * pi)) ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
X = math.fabs((H + M / 60) / 12 - M / 60)
X = math.cos(2 * math.pi * X)
print((A ** 2 + B ** 2 - 2 * A * B * X) ** 0.5)


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


import math
pi = math.pi
(a, b, h, m) = map(int, input().split())
ra = (60 * h + m) / 360 * 180
rb = 180 / 30 * m
r = abs(ra - rb)
if r > 2 * 180:
	r = 2 * 180 - r
ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(r * 2 * pi / 360))
print(f'{ans:.20f}')


import math
(A, B, H, M) = map(int, input().split())
a = math.pi
b = math.cos(a * ((60 * H - 11 * M) / 360))
Z = A ** 2 + B ** 2 - 2 * A * B * b
print(Z ** (1 / 2))


import sys
import math
(a, b, h, m) = map(int, input().split())
f = h / 12 * 360 - m / 60 * 360 + m / 60 / 12 * 360
print((a ** 2 + b ** 2 - 2 * b * a * math.cos(math.radians(f))) ** 0.5)


import math
(a, b, h, m) = map(int, input().split())
hh = 30 * h + 30 * m / 60
mh = 6 * m
re = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(hh - mh)))
print(re)


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


import math
(a, b, h, m) = list(map(int, input().split()))
ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.pi * (h / 6 + m / 360 - m / 30)))
print(ans)


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


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


import math
(A, B, H, M) = map(int, input().split())
print('{:.20}'.format(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(30 * H - 11 * M / 2)))))


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


from math import e, pi
(A, B, H, M) = map(int, input().split())
j = pi / 6j
print(abs(A * e ** ((H + M / 60) * j) - B * e ** (M / 5 * j)))


import math
(A, B, H, M) = map(int, input().split())
X = (A ** 2 + B ** 2 - 2 * A * B * math.cos(math.pi * 2 * ((H + M / 60) / 12 - M / 60))) ** (1 / 2)
print(X)


import math
(a, b, h, m) = map(int, input().split())
ang = abs(0.5 * (60 * h + m) - 6 * m)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.pi * ang / 180)))


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


import math
(a, b, h, m) = map(int, input().split())
h_rad = (h * 60 + m) * math.pi / 360
m_rad = m * math.pi / 30
cosine = math.cos(abs(h_rad - m_rad))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosine))


import math
(a, b, h, m) = map(int, input().split())
p = (h * 60 + m) / 720
q = m / 60
x = (p - q) * math.pi * 2
print((a ** 2 + b ** 2 - 2 * a * b * math.cos(x)) ** 0.5)


import math
(a, b, h, m) = list(map(int, input().split()))
x = 6 * m
y = 30 * h + 0.5 * m
C = max(x, y) - min(x, y)
C = min(C, 360 - C)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C))))


import math
(a, b, h, m) = [int(x) for x in input().split()]
p = math.pi
arg_h = 2 * p * h / 12 + m * p / 360
arg_m = 2 * p * m / 60
arg = abs(arg_h - arg_m)
c_2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(arg)
c = math.sqrt(c_2)
print(c)


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


import math
(A, B, H, M) = map(int, input().split())
k = M / 60
if H == 0:
	H = 12
if M == 0:
	M = 60
H_d = (H / 12 * 60 + k * 5) / 60 * 2 * math.pi
M_d = M / 60 * 2 * math.pi
r = abs(H_d - M_d)
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(r)))


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


(A, B, H, M) = map(int, input().split())
import math
Q = math.cos((math.pi / 30 - math.pi / 360) * (60 * H + M))
r = math.sqrt(A * A + B * B - 2 * A * B * Q)
print(r)


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


(a, b, h, m) = map(int, input().split())
from math import radians, cos
r = 30 * h - 6 * m + m / 2
r = radians(r)
e = a ** 2 + b ** 2 - 2 * a * b * cos(r)
print(e ** 0.5)


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


import math
(A, B, H, M) = list(map(int, input().split()))
if H == 0:
	H = 12
elif M == 0:
	M = 60
L = M / 5
N = min(abs(L - H), abs(H - L))
if L >= H:
	if M == 60:
		M = 0
	S = 360 * N / 12 - 0.5 * M
else:
	S = 360 * N / 12 + 0.5 * M
ANS = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(S))
ANS = math.sqrt(ANS)
print(ANS)


import math
(A, B, H, M) = map(int, input().split())
thetaA = math.pi * (0.5 * (H * 60 + M)) / 180
thetaB = math.pi * 6.0 * M / 180
theta = min(2 * math.pi - abs(thetaA - thetaB), abs(thetaA - thetaB))
cosC = math.cos(theta)
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * cosC)
print(ans)


import math
import numpy as np
(A, B, H, M) = list(map(int, input().split()))
thetaA = math.radians((H / 12 + 1 / 12 * M / 60) * 360)
thetaB = math.radians(M / 60 * 360)
a = np.array([A * math.sin(thetaA), A * math.cos(thetaA)])
b = np.array([B * math.sin(thetaB), B * math.cos(thetaB)])
print(round(np.linalg.norm(a - b), 11))


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


import math
(a, b, h, m) = list(map(int, input().split()))
total_minute = 60 * h + m
ax = a * math.cos(math.radians(360 - total_minute / 2 + 90))
ay = a * math.sin(math.radians(360 - total_minute / 2 + 90))
bx = b * math.cos(math.radians(360 - 6 * m + 90))
by = b * math.sin(math.radians(360 - 6 * m + 90))
kyori = math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)
print(kyori)


import math
(a, b, h, m) = map(int, input().split())
l = a ** 2 + b ** 2
k = 2 * a * b
p = math.pi
print((l - k * math.cos(abs(p * h / 6 - 11 * m * p / 360))) ** 0.5)


from math import *
(a, b, h, m) = [int(_) for _ in input().split()]
print((a ** 2 + b ** 2 - 2 * a * b * cos(radians(h * 330 + m * 5.5))) ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
x = math.radians(H * 30 - M * 5.5)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(x)) ** 0.5)


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


import sys
import math
from decimal import Decimal

def input():
	return sys.stdin.readline().rstrip()
(A, B, H, M) = map(float, input().split())
minute = H * 60 + M
short = minute / (60 * 12) * 2 * math.pi
long = M / 60 * 2 * math.pi
rad = abs(long - short)
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))
print(ans)


(A, B, H, M) = map(int, input().split())
import math
k = math.cos(math.pi * (H / 6 - 11 * M / 360))
L = (A ** 2 + B ** 2 - 2 * A * B * k) ** 0.5
print(L)


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


import math
(a, b, h, m) = map(int, input().split())
t = math.radians(abs((60 * h - 11 * m) / 2))
print((a ** 2 + b ** 2 - 2 * a * b * math.cos(t)) ** 0.5)


import math
(a, b, h, m) = map(int, input().split())
t = math.pi * (60 * h - 11 * m) / 360
l = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(t))
print(l)


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


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)


import math
(A, B, H, M) = map(int, input().split())
h_theta = 2 * math.pi * (H + M / 60) / 12
m_theta = 2 * math.pi * M / 60
dx = A * math.cos(h_theta) - B * math.cos(m_theta)
dy = A * math.sin(h_theta) - B * math.sin(m_theta)
print(math.sqrt(dx ** 2 + dy ** 2))


import math
(A, B, H, M) = map(int, input().split())
d = M / 2
x = (H * 5 * 6 + d - M * 6) * math.pi / 180
c = (A * A + B * B - 2 * A * B * math.cos(x)) ** (1 / 2)
print(c)


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


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


import math
(a, b, h, m) = map(int, input().split())
m_radians = 360 * m / 60
h_radians = 360 * ((h * 5 + 5 * m / 60) / 60)
cos_ab = math.cos(math.radians(h_radians - m_radians))
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos_ab)
print(c)


import math
(A, B, H, M) = list(map(int, input().split()))
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos((30 * H - 5.5 * M) * math.pi / 180)))


(A, B, H, M) = map(float, input().split())
import math
rad_min = 2.0 * math.pi * M / 60
rad_hour = 2.0 * math.pi * H / 12.0 + math.pi / 6.0 * M / 60.0
rad = abs(rad_min - rad_hour)
l = math.sqrt(A ** 2 + B ** 2 - 2.0 * A * B * math.cos(rad))
print(l)


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


import math
[A, B, H, M] = [int(i) for i in input().split()]
x = 5.5 * (60 * H + M)
c = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(x))
print(c ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
angle_A = 6 * M
angle_B = 30 * (H + M / 60)
angle_C = abs(angle_A - angle_B)
rad_C = math.radians(angle_C)
C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad_C))
print(C)


import math
(A, B, H, M) = map(int, input().split())
t = abs(30 * H - 5.5 * M)
cos_t = math.cos(math.radians(t))
print((A ** 2 + B ** 2 - 2 * A * B * cos_t) ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
angle = H * 30 + 30 * (M / 60) - M * 6
abs_angle = abs(angle)
if abs_angle > 180:
	abs_angle = 360 - abs_angle
abs_angle = math.cos(math.radians(abs_angle))
ans_sqrt = A ** 2 + B ** 2 - 2 * A * B * abs_angle
print(math.sqrt(ans_sqrt))


import math

def colon():
	(A, B, H, M) = map(int, input().split())
	h = 30 * H
	h = h - 5.5 * M
	h = min(h, 360 - h)
	h = h * math.pi / 180
	res = A ** 2 + B ** 2 - 2 * A * B * math.cos(h)
	print(res ** 0.5)
colon()


(A, B, H, M) = map(int, input().split())
import math
x = abs((60 * H + M) / 2 - 6 * M)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(x))) ** (1 / 2))


import numpy as np
(a, b, h, m) = list(map(int, input().split()))
pos1 = [b * np.sin(np.radians(6 * m)), b * np.cos(np.radians(6 * m))]
pos2 = [a * np.sin(np.radians(30 * h + m * (360 / (12 * 60)))), a * np.cos(np.radians(30 * h + m * (360 / (12 * 60))))]
d = ((pos1[0] - pos2[0]) ** 2 + (pos1[1] - pos2[1]) ** 2) ** 0.5
print(d)


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


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)


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


(A, B, H, M) = map(int, input().split())
import math
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(5.5 * M - 30 * H))) ** (1 / 2))


(a, b, h, m) = map(int, input().split())
import math
t = abs(math.pi * ((h + m / 60) / 6) - math.pi * m / 30)
r = (a ** 2 - 2 * a * b * math.cos(t) + b ** 2) ** 0.5
print(r)


import math
(a, b, h, m) = map(int, input().split())
theta = abs(30 * h - 11 * m / 2)
print((a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(theta))) ** 0.5)


import math
(a, b, h, m) = map(int, input().split())
k = 30 * (h + m / 60) - 6 * m
c = (a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(k))) ** (1 / 2)
print(c)


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


from math import cos, radians

def answer(a: int, b: int, h: int, m: int) -> float:
	num = abs((60 * h - 11 * m) / 2)
	theta = min(num, 360 - num)
	return pow(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(radians(theta)), 1 / 2)

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

def __starting_point():
	main()
__starting_point()


import math
(A, B, H, M) = map(int, input().split())
theta = (H / 6 - 11 * M / 360) * math.pi
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)))


from math import cos, radians
(a, b, h, m) = map(int, input().split())
th = (h + m / 60) * 30 - m * 6
l = a ** 2 + b ** 2 - 2 * a * b * cos(radians(th))
print(l ** (1 / 2))


import math
(A, B, H, M) = map(int, input().split())
aH = 30 * H + 0.5 * M
aM = 6 * M
r = abs(aH - aM)
a = A * A + B * B - 2 * A * B * math.cos(math.radians(r))
print(a ** 0.5)


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


import math
(A, B, H, M) = map(float, input().split())
l = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos((660 * H + 11 * M) * math.pi / 360))
print(l)


(a, b, h, m) = map(int, input().split())
import math
print((a * a + b * b - 2 * a * b * math.cos(math.radians(360 * abs(h / 12 + 1 / 12 * m / 60 - m / 60)))) ** 0.5)


import math
(a, b, h, m) = map(int, input().split())
p = math.pi
ang = p / 30 * m - (p / 6 * h + p / 360 * m)
print(abs(a ** 2 + b ** 2 - 2 * a * b * math.cos(ang)) ** 0.5)


import math
(a, b, h, m) = (float(x) for x in input().split())
x = h * math.pi / 6 + m * math.pi / 360
y = m * math.pi / 30
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(x - y)))


import numpy as np
(A, B, H, M) = list(map(int, input().split()))
angle_h = 1.0 / 12.0 * (H + M / 60.0) * 2 * np.pi
angle_m = M / 60.0 * 2 * np.pi
hour = (A * np.sin(angle_h), A * np.cos(angle_h))
minute = (B * np.sin(angle_m), B * np.cos(angle_m))
dist = np.sqrt((hour[0] - minute[0]) ** 2 + (hour[1] - minute[1]) ** 2)
print(dist)


import cmath
(a, b, h, m) = map(int, input().split(' '))
print(abs(a * cmath.exp(1j * (h + m / 60) * cmath.pi / 6) - b * cmath.exp(1j * m * 2 * cmath.pi / 60)))


import math
(A, B, H, M) = map(int, input().split())
C2 = A * A + B * B - 2 * A * B * math.cos(math.pi * (H * 60 + M - 12 * M) / 360)
print(math.sqrt(C2))


import math
(a, b, h, m) = map(int, input().split())
lrad = 6 * m
srad = 30 * h + 0.5 * m
if abs(lrad - srad) <= 180:
	do = abs(lrad - srad)
else:
	do = 360 - abs(lrad - srad)
rad = math.radians(do)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)))


import math
(A, B, H, M) = map(int, input().split())
c = abs(H * 30 - M * 5.5)
k = A * A + B * B - 2 * A * B * math.cos(c * math.pi / 180)
l = math.sqrt(k)
print(l)


import math
import numpy as np

def rot_rev(t, v):
	R = np.array([[np.cos(t), np.sin(t)], [-np.sin(t), np.cos(t)]])
	return np.dot(R, v)
(A, B, H, M) = list(map(int, input().split()))
H_rad = (H * 60 + M) / (12 * 60) * 2 * np.pi
M_rad = M / 60 * 2 * np.pi
P_A = (0, A)
P_B = (0, B)
rot_A = rot_rev(H_rad, P_A)
rot_B = rot_rev(M_rad, P_B)
print(np.linalg.norm(rot_A - rot_B))


(a, b, c, d) = map(int, input().split())
c = (c * 60 + d) * 0.5
d *= 6
import math
ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(min(abs(d - c), 360 - abs(d - c))))
print(ans ** 0.5)


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


import numpy as np
(a, b, h, m) = list(map(int, input().split()))
theta = abs(h / 12 - 11 * m / 720) * 2 * np.pi
print(np.sqrt(a * a + b * b - 2 * a * b * np.cos(theta)))


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


import math
(A, B, H, M) = map(int, input().split())
d = abs((H * 60 + M) * 0.5 - M * 6)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(d))) ** 0.5)


import math
(A, B, H, M) = list(map(int, input().split()))
h = H * 30 + M / 2
m = M * 6
t = max(m, h) - min(m, h)
theta = min(t, 360 - t)
c = A ** 2 + B ** 2 - 2 * A * B * math.cos(theta / 180 * math.pi)
print(math.sqrt(c))


import math
(A, B, H, M) = map(float, input().split())
C = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(abs(H * 30 + M * 0.5 - M * 6)))
print(C ** (1 / 2))


import math

def main() -> None:
	(a, b, h, m) = list(map(int, input().split()))
	theta = abs(30 * h - 5.5 * m)
	cos_theta = math.cos(math.radians(theta))
	print((a ** 2 + b ** 2 - 2 * a * b * cos_theta) ** 0.5)
	return

def __starting_point():
	main()
__starting_point()


import math
(A, B, H, M) = map(int, input().split())
at = (60 * H + M) / (12 * 60) * 2 * math.pi
bt = M / 60 * 2 * math.pi
ax = A * math.sin(at)
ay = A * math.cos(at)
bx = B * math.sin(bt)
by = B * math.cos(bt)
print(((ax - bx) ** 2 + (ay - by) ** 2) ** 0.5)


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)


import math
(a, b, h, m) = list(map(int, input().split()))
s = 3600 * h + 60 * m
radh = (s / (60 * 60 * 12) - int(s / (60 * 60 * 12))) * 2 * math.pi
radm = (s / (60 * 60) - int(s / (60 * 60))) * 2 * math.pi
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(radh - radm))
print(c)


import math
(A, B, H, M) = map(int, input().split())
P = H * 30 - M * 5.5
c = math.cos(math.radians(P))
L = A * A + B * B - 2 * A * B * c
x = math.sqrt(L)
print(x)


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


import math
import numpy as np
(a, b, h, m) = list(map(int, input().split()))
a_radian = math.radians(h * 30 + m / 2)
a_ = np.array([a * math.cos(a_radian), a * math.sin(a_radian)])
b_radian = math.radians(6 * m)
b_ = np.array([b * math.cos(b_radian), b * math.sin(b_radian)])
print(np.linalg.norm(a_ - b_))


(A, B, H, M) = map(int, input().split())
theta = abs((0.5 * (H * 60 + M) - 6 * M) % 360)
if theta > 180:
	theta = 360 - theta
import math
C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta / 180 * math.pi))
print(C)


import math
(a, b, H, M) = map(int, input().split())
print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(2 * math.pi * (H / 12.0 - 11 / 12.0 * M / 60.0))))


import math
(A, B, H, M) = map(int, input().split())
h = (H / 12 + M / 60 / 12) * 360
m = M / 60 * 360
r = min(abs(h - m), 360 - abs(h - m))
ans = (A ** 2 + B ** 2 - 2 * B * A * math.cos(math.radians(r))) ** (1 / 2)
print(ans)


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


import math
(A, B, H, M) = map(int, input().split())
a = A ** 2
b = B ** 2
c = A * B * 2
h = math.pi * 2 * (H / 12 + M / 720 - M / 60)
z = a + b - c * math.cos(h)
print(math.sqrt(z))


import math
(a, b, h, m) = map(int, input().split())
ha = (h * 60 + m) / 360 * math.pi
ma = m / 30 * math.pi
(sh, ch) = (math.sin(ha), math.cos(ha))
(sm, cm) = (math.sin(ma), math.cos(ma))
print(((a * sh - b * sm) ** 2 + (a * ch - b * cm) ** 2) ** (1 / 2))


import math
pi = 3.141592653589793
(h, m, H, M) = map(int, input().split())
print(math.sqrt(h ** 2 + m ** 2 - 2 * h * m * math.cos(2 * pi * (30 * H - 5.5 * M) / 360)))


import math as m
(A, B, H, M) = list(map(int, input().split()))
print(m.sqrt(A ** 2 + B ** 2 - 2 * A * B * m.cos(m.radians(30 * H - 11 * M / 2))))


import math
x = list(map(int, input().split()))
A = x[0]
B = x[1]
H = x[2]
M = x[3]
y = 2 * math.pi * ((H * 60 + M) / 720 - M / 60)
z = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(y))
print(z)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, bisect
import sys
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
stdin = sys.stdin
ni = lambda : int(ns())
nf = lambda : float(ns())
na = lambda : list(map(int, stdin.readline().split()))
nb = lambda : list(map(float, stdin.readline().split()))
ns = lambda : stdin.readline().rstrip()
(A, B, H, M) = na()
l = 360 / 12 * (H + M / 60)
s = 360 / 60 * M
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(abs(l - s) * math.pi / 180)))


import math
(A, B, H, M) = map(int, input().split())
thetaA = math.pi * H / 6 + math.pi * M / 360
thetaB = math.pi * M / 30
Ax = A * math.cos(thetaA)
Ay = A * math.sin(thetaA)
Bx = B * math.cos(thetaB)
By = B * math.sin(thetaB)
X = Ax - Bx
Y = Ay - By
ans = (X ** 2 + Y ** 2) ** 0.5
print(ans)


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


import math
(A, B, H, M) = map(int, input().split())
t = (H * 1 / 6 - M * 11 / 360) * math.pi
C = A ** 2 + B ** 2 - 2 * A * B * math.cos(t)
print(C ** 0.5)


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


import math
(A, B, H, M) = map(int, input().split())
sitaH = (H * 60 + M) / 720 * 2 * math.pi
sitaM = M / 60 * 2 * math.pi
posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)
delX = posXH - posXM
delY = posYH - posYM
d = (delX * delX + delY * delY) ** (1 / 2)
print(d)


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


import math

def main():
	(a, b, h, m) = map(int, input().split(' '))
	r1 = h * 30 + m / 2
	r2 = 6 * m
	r3 = abs(r1 - r2)
	print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(r3))))

def __starting_point():
	main()
__starting_point()


import math
(A, B, H, M) = map(int, input().split())
if H >= 12:
	H -= 12
choperminute = 360 / 60
tanperminute = 30 / 60
tankaku = H * 30 + tanperminute * M
chokaku = choperminute * M
if chokaku >= tankaku:
	angle = chokaku - tankaku
else:
	angle = tankaku - chokaku
if angle > 180:
	angle = 360 - angle
ansjyou = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(angle))
print(ansjyou ** 0.5)


import math
(A, B, H, M) = list(map(int, input().split()))
theta = (M * 11 / 360 - H / 6) * math.pi
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)) ** 0.5)
return


import math
(a, b, h, m) = list(map(int, input().split()))
minutes = m / 60 * 2 * math.pi
hour = (60 * h + m) / 720 * 2 * math.pi
theta = abs(hour - minutes)
x = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(theta))
print(x)


(A, B, H, M) = list(map(int, input().split()))
import math
x = H / 12 * 360 + M / 60 * 30
y = M / 60 * 360
ang = abs(y - x)
ans_2 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(ang))
ans = math.sqrt(ans_2)
print(ans)


import math
(a, b, h, m) = map(float, input().split())
c = abs(30 * h - 11 / 2 * m)
ct = math.radians(c)
cos = math.cos(ct)
ans = a ** 2 + b ** 2 - 2 * a * b * cos
print(math.sqrt(ans))


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)


import math
(a, b, h, m) = map(int, input().split())
kaku = math.cos(math.radians(abs((h * 60 + m) / 2 - m * 6)))
print((a ** 2 + b ** 2 - 2 * a * b * kaku) ** (1 / 2))


import math
(A, B, H, W) = map(int, input().split())
R = abs(30 * H + 0.5 * W - 6 * W)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(R))) ** 0.5)


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


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


import math
(A, B, H, M) = map(int, input().split())
cosM = math.cos(math.radians(30 * H - 11 * M / 2))
D = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * cosM)
print(D)


import numpy as np
(a, b, h, m) = map(int, input().split())
hour_theta = np.pi * (60 * h + m) / 360
minute_theta = np.pi * m / 30
theta = abs(hour_theta - minute_theta)
ans = np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(theta))
print('{:.11f}'.format(ans))


import math
(a, b, h, m) = list(map(int, input().split()))
arg = min(abs(30 * h - 5.5 * m), 360 - abs(30 * h - 5.5 * m))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(arg))))


import math
(a, b, c, d) = map(int, input().split())
s = 6 * d
l = 30 * c + 0.5 * d
cosx = math.cos(math.radians(l - s))
print((a ** 2 + b ** 2 - 2 * a * b * cosx) ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
r = 2 * math.pi * abs(H / 12 + M / 60 / 12 - M / 60)
a = A ** 2 + B ** 2 - 2 * A * B * math.cos(r)
a = math.sqrt(a)
print(a)


(a, b, c, d) = input().split()
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = 60 * c + d
f = abs(0.5 * e - 6 * e)
f = f % 360
if f > 180:
	f = 360 - f
import math
print(math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(f))))


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


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


import math
(a, b, h, m) = map(int, input().split())
x = math.pi * h / 6 - math.pi * m / 30 + math.pi * m / 360
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(x))
print(c)


import math
from decimal import Decimal
(hour_len, minute_len, hour, minute) = list(map(int, input().split()))
rad_h = math.radians(Decimal((hour * 60 + minute) / 720 * 360))
rad_m = math.radians(Decimal(minute / 60 * 360))
cos_hm = math.cos(abs(Decimal(rad_h - rad_m)))
a_double = hour_len ** 2 + minute_len ** 2 - 2 * hour_len * minute_len * cos_hm
ans = math.sqrt(a_double)
print(f'{ans:.20f}')


from collections import Counter
import sys
import math
sys.setrecursionlimit(10 ** 6)
mod = 1000000007
inf = int(1e+18)

def main():
	(a, b, h, m) = list(map(int, input().split()))
	x1 = a * math.cos(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
	y1 = a * math.sin(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
	x2 = b * math.cos(2 * math.pi * (m / 60))
	y2 = b * math.sin(2 * math.pi * (m / 60))
	print(((x1 - x2) ** 2 + (y1 - y2) ** 2) ** (1 / 2))
main()


import math
(A, B, H, M) = list(map(int, input().split()))
theta = abs((H + M / 60) / 12 - M / 60) * 2 * math.pi
ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(theta))
print(ans)


import math
(a, b, h, m) = map(int, input().split())
q = h * 30 + m * 0.5
w = m * 6
cosa = math.cos(math.radians(q - w))
print((a ** 2 + b ** 2 - 2 * a * b * cosa) ** 0.5)


import math
(A, B, H, M) = map(int, input().split())
C2 = A ** 2 + B ** 2 - 2 * A * B * math.cos((30 * H - 11 * M / 2) / 180 * math.pi)
print(C2 ** (1 / 2))


import numpy as np
(A, B, H, M) = map(int, input().split())
pi = np.pi
h_angle = (H + M / 60) * 2 * pi / 12
m_angle = M * 2 * pi / 60
h_x = A * np.cos(h_angle)
h_y = A * np.sin(h_angle)
m_x = B * np.cos(m_angle)
m_y = B * np.sin(m_angle)
print(np.sqrt((h_x - m_x) ** 2 + (h_y - m_y) ** 2))


import math
(a, b, h, m) = map(int, input().split())
r_a = 30 * h + 0.5 * m
r_b = 6 * m
rad = math.pi * (r_a - r_b) / 180
ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad))
print(ans)


import math
(A, B, H, M) = map(float, input().split())
c = A * A + B * B - 2.0 * A * B * math.cos(math.radians((11.0 * M - 60.0 * H) / 2))
print(math.sqrt(c))


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


import math

def cal(H, M):
	H = 360 / 12 * H + 1 / 12 * (M / 60) * 360
	M = 360 / 60 * M
	H_M = abs(H - M)
	if H_M > 180:
		H_M = 360 - H_M
	return H_M

def main():
	(A, B, H, M) = map(int, input().split())
	angle = cal(H, M)
	if angle == 180:
		print(A + B)
	else:
		print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(angle))))
main()


import math
(A, B, H, M) = map(int, input().split())
X = H * 30 + M * 0.5
Y = M * 6
t = (X - Y) * math.pi / 180
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(t)))


import math
(a, b, h, m) = list(map(int, input().split()))
ang = h * 30 - m * 11 / 2
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(ang)))
print(c)