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

an_a = 2/12*h + (1/6)*(m/60)
an_b = 2/60*m

angle = an_a - an_b
if angle > 1:
    angle = 2 - angle

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

Solution (Python):
import math

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

hrad = math.radians(90 - 30 * h - m / 2)
mrad = math.radians(90 - 6 * m)

ax = a * math.sin(hrad)
ay = a * math.cos(hrad)

bx = b * math.sin(mrad)
by = b * math.cos(mrad)

ret = math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)

print(ret)

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes) if b else print(no)


import math


a,b,h,m=n1()

m1=m*360/60
h1=(60*h+m)*360/(12*60)
d=min(abs(m1-h1),360-abs(m1-h1))
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(d)))
print(ans)

Solution (Python):
import os

import math
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


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

h = (H / 12 + M / (12 * 60)) * math.pi * 2
m = M / 60 * math.pi * 2

theta = abs(h - m)
if theta > math.pi * 2:
    theta = math.pi * 2 - theta
cc = A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)
ans = math.sqrt(cc)
print(ans)

Solution (Python):
import math

def solve(a,b,h,m):
    rad_a = 2*math.pi*((h+m/60)/12)
    rad_b = 2*math.pi*(m/60)

    x_a = a*math.cos(rad_a)
    y_a = a*math.sin(rad_a)
    x_b = b*math.cos(rad_b)
    y_b = b*math.sin(rad_b)

    res = math.sqrt((x_a-x_b)**2 + (y_a-y_b)**2)

    return res




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

Solution (Python):
from math import cos
from math import radians as rad

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

alp=rad(30*H+M/2)
bet=rad(6*M)

ans=(A**2+B**2-2*B*A*cos(alp-bet))**0.5
print(ans)

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

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

A, B, H, M = [int(i) for i in input().split()]
time = 60*H + M
hoge = time * 0.5 - 6*M
d = min(abs(hoge), abs(360-hoge))

c = cos(radians(d))

res = sqrt(-(c*2*A*B-A**2-B**2))
print(res)

Solution (Python):
import math

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

tyousin = m * 6
tansin = (h*60+m) * 0.5
kakudo = max(tyousin,tansin) - min(tyousin,tansin)
kakudo = min(kakudo,360-kakudo)
kosain = math.cos(math.radians(kakudo))

ans = (a**2 + b **2 - 2*a*b*kosain)**0.5
print(ans)

Solution (Python):
import math

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

arg1=30*h+0.5*m
arg2=6*m
arg=math.radians(abs(arg1-arg2))

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,cos,radians,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b,h,m=MI()
rad=radians(6*m-m/2-30*h)
print(sqrt(a**2+b**2-2*a*b*cos(rad)))

Solution (Python):
import math

p = math.pi

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

b = 6 * M
xb = B * math.cos(b * 2 * p / 360)
yb = B * math.sin(b * 2 * p / 360)

a = 30 * H + 0.5 * M
xa = A * math.cos(a * 2 * p / 360)
ya = A * math.sin(a * 2 * p / 360)

diff = (xa - xb) ** 2 + (ya - yb) ** 2
ans = math.sqrt(diff)

print (ans)

Solution (Python):
import math

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

h_p = (H + M / 60) * 30
m_p = M * 6

ang = abs(h_p - m_p)

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

Solution (Python):
import math
A,B,H,M=map(int,input().split())
pi=3.14159265358979
time=H*60+M
Hth=pi/360*time
Mth=pi/30*time
theta=min(abs(Hth-Mth),abs(Mth-Hth))
l=(A**2+B**2-2*A*B*math.cos(theta))**0.5
print(l)

Solution (Python):
import math

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

min_angle = 2 * math.pi * m / 60
hour_angle = 2 *math.pi * (h / 12 + m / 720)

min_pos = (math.cos(min_angle) * b, math.sin(min_angle) * b)
hour_pos = (math.cos(hour_angle) * a, math.sin(hour_angle) * a)

print(math.sqrt((min_pos[0] - hour_pos[0]) ** 2 + (min_pos[1] - hour_pos[1]) ** 2))

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

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

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

aa = ha - ma

if aa < -180:
    aa += 360
elif aa > 180:
    aa = 360 - aa
else:
    aa = abs(aa)

bb = aa * math.pi / 180
cc = a * a + b * b - 2 * a * b * math.cos(bb)

print(cc ** (1/2))

Solution (Python):
import sys
import numpy as np


def inputs(func=lambda x: x, sep=None, maxsplit=-1):
	return map(func, sys.stdin.readline().split(sep=sep, maxsplit=maxsplit))

def input_row(n : int, type=np.int, **kwargs):
	return np.fromiter(inputs(type, **kwargs), dtype=type)

def input_2d(nrows : int, ncols : int, type=np.int, **kwargs):
	data = np.zeros((nrows, ncols), dtype=type)
	for i in range(nrows):
		data[i, :] = input_row(ncols, type, **kwargs)
	return data

from math import cos, sin, pi, sqrt

A, B, H, M = inputs(int)
t = H * 60 + M
hour_stick = A * cos(2 * pi * t / 720), A * sin(2 * pi * t / 720)
minute_stick = B * cos(2 * pi * t / 60), B * sin(2 * pi * t / 60)
difference = hour_stick[0] - minute_stick[0], hour_stick[1] - minute_stick[1]
distance = sqrt(sum(x * x for x in difference))

print(distance)

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

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

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

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

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



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

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

Solution (Python):
import math

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


pi=math.pi
h=h*60+m
x=max(2*pi*h/(12*60),2*pi*m/60)-min(2*pi*h/(12*60),2*pi*m/60)

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

Solution (Python):
import math

def main():
    A, B, H, M = tuple(int(c) for c in input().split(' '))

    h = 2*math.pi / 12 * (H + M / 60)
    m = 2*math.pi / 60 * M

    xh = A * math.cos(h)
    yh = A * math.sin(h)
    xm = B * math.cos(m)
    ym = B * math.sin(m)

    distance = ((xh-xm)**2 + (yh-ym)**2)**0.5
    print(distance)

if __name__ == "__main__":
    main()

Solution (Python):





import math

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

Dig = abs(30*H - 5.5*M)

if Dig > 180:
    Dig = 360 - Dig

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

ans = ans**0.5

print(ans)

Solution (Python):
import math
a, b, h, m = map(int,input().split())
H = h + m / 60
hour = H / 6
minute = H * 2
print((a**2 + b**2 - 2*a*b*math.cos((hour-minute)*math.pi))**(1/2))

Solution (Python):
a, b, h, m = map(int, input().split())
import math
vx = 2*math.pi/(12*60)
vy = 2*math.pi/60

x = vx*(60*h+m)
y = vy*m

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

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

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

res = (a**2 + b**2 -2*a*b*math.cos(math.radians(han-man)))**0.5
print(res)

Solution (Python):
import math 
A, B, H, M = [int(x) for x in input().split(' ')]
theta_h = math.pi * (H / 6 + M / 360)
theta_m = math.pi * (M / 30)
theta = theta_h - theta_m
x = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
print(x)

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

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

Solution (Python):
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)

Solution (Python):
import math

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

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

m_angle = 2*math.pi*m/60

theta = abs(h_angle-m_angle)

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

Solution (Python):
import math
from decimal import Decimal

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

a, b, h, m = ML()

h += m/60

x1 = a*math.cos(h/6*math.pi)
y1 = a*math.sin(h/6*math.pi)

x2 = b*math.cos(m/30*math.pi)
y2 = b*math.sin(m/30*math.pi)

distance = Decimal(math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2))

print(distance)

Solution (Python):
import math

a,b,x,y = map(int,input().split())

s = 6*y
t = 30*x+y/2

_th = abs(s-t)
__th = min(_th,360-_th)
p = math.pi
th = __th*p/180
co = math.cos(th)

c2 = a**2+b**2-2*b*a*co
print(c2**(1/2))

Solution (Python):
import sys
import math
import itertools
import numpy

rl = sys.stdin.readline
a, b, h, m = map(int, rl().split())
theta = (h*60 + m) * 0.5
theta1 = m * 6
theta = abs(theta-theta1)
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(theta))
c = c**0.5
print(c)

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

rada=(h+m/60)*30
radb=(6*m)
rad=rada-radb
print((a**2+b**2-2*a*b*math.cos(math.radians(rad)))**(1/2))

Solution (Python):















import math

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

    minutes = H * 60 + M

    theta_A = 2 * math.pi * minutes / 720
    rad_A = math.pi / 2 - theta_A
    pos_A = (A * math.cos(rad_A), A * math.sin(rad_A))

    theta_B = 2 * math.pi * minutes / 60
    rad_B = math.pi / 2 - theta_B
    pos_B = (B * math.cos(rad_B), B * math.sin(rad_B))

    dist = math.sqrt((pos_A[0]-pos_B[0])**2 + (pos_A[1]-pos_B[1])**2)

    return dist


def main():
    print(solve())


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read


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

x = 30*h+30*m/60
y = 6*m

from math import cos, pi, sqrt
theta = (x-y)*2*pi/360
print(sqrt(max(a*a+b*b-2*a*b*cos(theta),0)))

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

ho=(360/720)*(h*60+m)

mi=(360/60)*m
sita1=abs(mi-ho)
sita2=360-sita1
sita=min(sita1,sita2)
x=math.sqrt(a**2 + b**2 -2*a*b*math.cos(sita*math.pi/180))
print(x)

Solution (Python):

import sys

sysread = sys.stdin.readline
read = sys.stdin.read


sys.setrecursionlimit(10**7)
import math




def run():
    A,B,H,M = map(int, input().split())
    t_h = (H + M /60) / 12 * 2 * math.pi
    xh = A * math.cos(t_h)
    yh = A * math.sin(t_h)

    t_m = M * math.pi / 30
    xm = B * math.cos(t_m)
    ym = B * math.sin(t_m)

    L = (xh - xm) ** 2 + (yh - ym) ** 2
    L = math.sqrt(L)
    print(L)

if __name__ == "__main__":
    run()

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

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

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

hour = h + m / 60
long_rad = -(2 * pi * m / 60) + pi / 2
short_rad = -(2 * pi * hour / 12) + pi / 2

long_pos = [b * cos(long_rad), b * sin(long_rad)]
short_pos = [a * cos(short_rad), a * sin(short_rad)]
distance = sqrt(((long_pos[0] - short_pos[0])**2 + (long_pos[1] - short_pos[1])**2))
print(distance)

Solution (Python):
import math

a,b,h,m=map(int,input().split())
deg1=h*30+m*0.5
x1,y1=0,0
if deg1<=90:
  x1=a*math.sin(2*math.pi*(deg1/360))
  y1=a*math.cos(2*math.pi*(deg1/360))
elif deg1<=180:
  x1=a*math.sin(2*math.pi*((180-deg1)/360))
  y1=-a*math.cos(2*math.pi*((180-deg1)/360))
elif deg1<=270:
  x1=-a*math.sin(2*math.pi*((deg1-180)/360))
  y1=-a*math.cos(2*math.pi*((deg1-180)/360))
elif deg1<=360:
  x1=-a*math.sin(2*math.pi*((360-deg1)/360))
  y1=a*math.cos(2*math.pi*((360-deg1)/360))
deg2=m*6
x2,y2=0,0
if deg2<=90:
  x2=b*math.sin(2*math.pi*(deg2/360))
  y2=b*math.cos(2*math.pi*(deg2/360))
elif deg2<=180:
  x2=b*math.sin(2*math.pi*((180-deg2)/360))
  y2=-b*math.cos(2*math.pi*((180-deg2)/360))
elif deg2<=270:
  x2=-b*math.sin(2*math.pi*((deg2-180)/360))
  y2=-b*math.cos(2*math.pi*((deg2-180)/360))
elif deg2<=360:
  x2=-b*math.sin(2*math.pi*((360-deg2)/360))
  y2=b*math.cos(2*math.pi*((360-deg2)/360))
ans=math.sqrt((x1-x2)**2+(y1-y2)**2)
print(ans)

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

Solution (Python):
a,b,h,m = map(int,input().split())
import math
t1 = 30 *(h+m/60)
t2 = 6 * m

x1 = a*math.cos(math.radians(t1))
y1 = a*math.sin(math.radians(t1))

x2 = b*math.cos(math.radians(t2))
y2 = b*math.sin(math.radians(t2))

ans = ((x1-x2)**2 + (y1-y2)**2)**0.5
print(ans)

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

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

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

h = 30 * H + (M / 2)
m = 6 * M

print(sqrt(A**2 + B**2 - 2*A*B*cos(radians(abs(h-m)))))

Solution (Python):
import math
A, B, H, M = map(int, input().split())
hour_rad = math.pi / 2 - 2 * math.pi * (60 * H + M) / 720
hour_x = A * math.cos(hour_rad)
hour_y = A * math.sin(hour_rad)
min_rad = math.pi / 2 - 2 * math.pi * M / 60
min_x = B * math.cos(min_rad)
min_y = B * math.sin(min_rad)
print("{:.15f}".format(math.sqrt((hour_x - min_x) ** 2 + (hour_y - min_y) ** 2)))

Solution (Python):
import math
math.sin(math.radians(30))
a, b, h, m = list(map(int, input().split()))
a_angle = 30*h + 30 * m / 60.0
b_angle = 360 * m / 60.0
angle = abs(a_angle - b_angle)

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

Solution (Python):
import math

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

omega_A = 360 / (12 * 60)  
omega_B = 360 / 60  

deg_A = omega_A * (H * 60 + M)
deg_B = omega_B * (H * 60 + M)

theta = abs(deg_A - deg_B)

c = A**2 + B**2 - 2 * A * B * math.cos(theta / 180 * math.pi)

print(math.sqrt(c))

Solution (Python):
import math
A, B, H, M = map(int, input().split())
rH = 360 * (H + (M/60))/12
rM = 360 * (M/60)
if(rH >= rM):
  rHOM = min(rH-rM, 360-(rH-rM))
else:
  rHOM = min(rM-rH, 360-(rM-rH))
  
cos = math.cos(math.radians(rHOM))

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

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


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

x = pi / 2 - 2 * pi * M / 60
y = pi / 2 - 2 * pi * (60 * H + M) / 720

x1, y1 = (B * cos(x), B * sin(x))
x2, y2 = (A * cos(y), A * sin(y))

l = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
print(l)

Solution (Python):
from math import sin, cos, sqrt, acos
PI = acos(-1)
A, B, H, M = map(int,input().split())
t = H*60+M
Ht, Mt = t*PI/360, t*PI/30
Hx, Hy = A*cos(Ht), A*sin(Ht)
Mx, My = B*cos(Mt), B*sin(Mt)
print(round(sqrt((Hx-Mx)**2+(Hy-My)**2),15))

Solution (Python):
from math import comb, factorial, gcd, isqrt, perm, exp, log, log2, log10, sqrt, pi, acos, asin, atan ,atan2, cos, sin, tan

a,b,h,m=map(int,input().split())
h%12
t=min(abs(30*h+0.5*m-6*m),360-abs(30*h+0.5*m-6*m))
c=(a**2+b**2-2*a*b*cos(pi*t/180))**0.5
print(c)

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


min_sum = 60 * h + m
h_d = math.radians(90 - 360*min_sum/720)
m_d = math.radians(90 - 360*m/60)

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

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

d2 = (h_x-m_x)**2 + (h_y-m_y)**2
ans = d2**0.5
print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
c,d=(h*60+m)/1440*math.pi*4,m/60*math.pi*2
print(((a*math.sin(c)-b*math.sin(d))**2+(a*math.cos(c)-b*math.cos(d))**2)**0.5)

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

Solution (Python):
def resolve():
    import math
    a, b, h, m = map(int, input().split())
    ms = m*6
    hs = h*30+m*0.5
    theta = abs(hs-ms)
    if theta >= 180:
        theta = 360-theta
    ans = a**2 + b**2 - 2*a*b*math.cos(math.radians(theta))
    ans = ans** 0.5
    print(ans)
resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,h,m=map(int,input().split())
    theta_a=(60*h+m)*2*math.pi/720
    theta_b=m*2*math.pi/60
    print(math.sqrt((a*math.cos(theta_a)-b*math.cos(theta_b))**2+(a*math.sin(theta_a)-b*math.sin(theta_b))**2))

if __name__=='__main__':
    main()

Solution (Python):
import math

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

a = 30 * H + 0.5 * M
b = 6 * M

s = math.radians(abs(a-b))

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

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


import math

degM = M*(360/60)
degH = H*(360/12) + M*(30/60)

deg = (degH - degM)

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

print(c)

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

T = (60*H+M) * 11 / 360 * math.pi
if T > math.pi:
    T = 2*math.pi - T

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

Solution (Python):
import math

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

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

angle = hangle - mangle

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

print(len)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *
from math import *

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

if 60*H+M>=12*M:
    rad = 30*H+M/2-6*M
else:
    rad = 6*M-(30*H+M/2)

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

print(ans**0.5)

Solution (Python):
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)

Solution (Python):
import math
A, B, H, M = map(int,input().split())
Ad = H * 30 + M * 0.5
Bd = M * 6
Ax, Ay = A * math.cos(math.radians(Ad)), A * math.sin(math.radians(Ad))
Bx, By = B * math.cos(math.radians(Bd)), B * math.sin(math.radians(Bd))
D = ((Ax-Bx)**2+(Ay-By)**2)**0.5
print(D)

Solution (Python):
import math
cos = math.cos
pi = 3.14159265358979323846264338
A, B, H, W = map(int, input().split())
tA = (H * 60 + W) / 2
tB = W * 6
theta = abs(tA - tB)
c = cos(theta*pi/180)
X = (A*A+B*B-2*A*B*c)
print(X**0.5)

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

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


h_degree = h*30+m*0.5
m_degree = m*6
degree = min(360-abs(h_degree-m_degree),abs(h_degree-m_degree))

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

Solution (Python):
import math

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


d1 = 360 * m / 60
d2 = 360 * h / 12 + m * 0.5

alpha = abs(d1 - d2)

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

Solution (Python):

import math
a,b,h,m = [int(x) for x in input().split()]
a_arg = math.pi*(h+m/60)/6
b_arg = math.pi*m/30
l_arg = 0
s_arg = 0
if a_arg >= b_arg:
    c2 = a**2 + b**2 - 2*a*b*math.cos(a_arg-b_arg)
else:
    c2 = a**2 + b**2 - 2*a*b*math.cos(b_arg-a_arg)
print(c2**0.5)

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

import math

x = 60*H+M

print(math.sqrt(A**2+B**2-2*A*B*math.cos((11*math.pi*x)/360)))

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

Solution (Python):
import math
def main():
    A, B, H, M = map(int, input().split())
    pi2 = 2.0 * math.pi
    ht = (H * 60.0 + M) * pi2 / (60.0 * 12)
    mt = pi2 * M / 60.0
    C = abs(ht - mt)
    c2 = A**2 + B**2 - 2 * A * B * math.cos(C)
    c = math.sqrt(c2)
    print(c)


if __name__ == '__main__':
    main()

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


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

angle = calcAngle(H,M)
angle_rag = math.radians(angle)
out = (A**2 + B**2 - 2 * A * B * math.cos(angle_rag))**0.5
print(out)

Solution (Python):
a,b,h,m=map(int,input().split())
import math
x=(2*math.pi*m)/60
y=(2*math.pi*(60*h+m))/720
x1=(a*math.cos(x),a*math.sin(x))
y2=(b*math.cos(y),b*math.sin(y))
J=(x1[0]-y2[0])**2+(x1[1]-y2[1])**2
print(math.sqrt(J))

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial, cos, radians
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


a, b, h, m = Is()
c = h*(360/12) + m*(30/60)
d = m*(360/60)
ans = sqrt(a**2+b**2-2*a*b*cos(radians(abs(c-d))))
print(ans)

Solution (Python):
import math

def get_pos(a, l):
  return (math.cos(a) * l, math.sin(a) * l)


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

(xh, yh) = get_pos((h * 60 + m) * (2 * math.pi) / (12 * 60), a)
(xm, ym) = get_pos(m * (2 * math.pi) / 60, b)
d = math.sqrt((xh - xm) ** 2 + (yh - ym) ** 2)

print(d)

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

    a1 = math.pi / 6 * (H + M / 60)
    a2 = math.pi * M / 30
    diff_a = a1 - a2

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

main()

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

time = 60*H + M
theta_a = time / 2

theta_b = 6*M

theta = abs(theta_a - theta_b)


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

Solution (Python):
import math

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

deg_a = (h+m/60)*30
deg_b = m*6
deg = deg_a-deg_b
cos_deg = math.cos(math.radians(deg))
ans = (a**2+b**2-2*a*b*cos_deg)**(1/2)

print(ans)

Solution (Python):
import math


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

M=H*60+M

theta=(5.5*M)%360

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

Solution (Python):
a, b, h, m = map(int, input().split())
x =( 60*h+m)/2
y = m*6
z = abs(x-y)
import math
s = b*math.sin(math.radians(z))
t = b*math.cos(math.radians(z))
r = ((abs(a-t))**2 + (s**2))**(.5)
print(r)

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

Solution (Python):
import math

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

a = (H * 60 + M) * 5.5 % 360
a = min(a, 360-a)
ans = A**2 + B**2 - 2 * A * B * math.cos(math.radians(a))
ans = ans**0.5

print(ans)

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

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

mrad = 2*np.pi/60*m
hrad = 2*np.pi/12*h + 2*np.pi/12/60*m

drad = min(abs(hrad - mrad), 2*np.pi-abs(hrad-mrad) )

tmp = a**2+b**2 - 2*a*b*np.cos(drad)

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

Solution (Python):
from math import sin,cos,pi
a,b,h,m = map(int,input().split())
def d(x0,y0,x1,y1):
    return ((x1-x0)**2+(y1-y0)**2)**(0.5)
t2 = ((h + (m/60))%12)/12*2*pi
t1 = (m/60)*2*pi
print(d(a*cos(t2),a*sin(t2),b*cos(t1),b*sin(t1)))

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

a = A * math.cos(math.radians(6 * M))
b = A * math.sin(math.radians(6 * M))
c = B * math.cos(math.radians(H*30+M/2))
d = B * math.sin(math.radians(H*30+M/2))

print(((c-a)**2 + (d-b)**2)**0.5)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

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

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

short = (0 + A * 1j)
short *= (math.cos(to_arg(short_rate)) + 1j * math.sin(to_arg(short_rate)))

long = (0 + B * 1j)
long *= (math.cos(to_arg(long_rate)) + 1j * math.sin(to_arg(long_rate)))

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

Solution (Python):
import math


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

    alpha = 30.0 * (H + M / 60.0)
    beta = 6 * M
    theta = alpha - beta

    l = math.sqrt(A ** 2 + B ** 2 - 2.0 * A * B * math.cos(math.radians(theta)))

    print(l)


if __name__ == '__main__':
    main()

Solution (Python):
from math import pi, cos
a, b, c, d = map(int, input().split())
x, y = (c+d/60)*pi/6, d*pi/30
s = abs(x-y)
r = a**2+b**2-2*a*b*cos(s)
print(r**0.5)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
theta_A = 2 * math.pi * (H * 60 + M) / 720
theta_B = 2 * math.pi * M / 60

xA, yA = A * math.sin(theta_A), A * math.cos(theta_A) 
xB, yB = B * math.sin(theta_B), B * math.cos(theta_B)

print(math.sqrt((xA - xB)**2 + (yA - yB)**2))

Solution (Python):

import sys
import math

def solve(A: int, B: int, H: int, M: int):
    A_angle = (360 * H) // 12 + (30 * M) / 60
    B_angle = 360 * M / 60
    theta = 2*math.pi * (abs(A_angle - B_angle)/ 360)
    ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))
    print(ans)
    return



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

if __name__ == '__main__':
    main()

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



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a, b, h, m = geta(int)

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

    dist2 = a**2 + b**2 - 2 * a * b * cos(ta - tb)

    print(sqrt(dist2))


if __name__ == "__main__":
    main()

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

    mins = H*60 + M

    degHo = mins / (12*60) * 360
    degMi = M / 60 * 360

    
    diff = abs(degHo - degMi)

    diff = min(diff,360-diff)

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



resolve()

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

x=(H+M/60)*pi/6
y=M*pi/30

if x==y:
    print(abs(A-B))
    exit()
    
C2=A**2+B**2-2*A*B*np.cos(abs(x-y))
print(pow(C2, 1/2))

Solution (Python):
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def read():
    A, B, H, M = map(int, input().strip().split())
    return A, B, H, M


def solve(A, B, H, M, INF = 10**8):
    t = H * 60 + M
    pi2 = math.pi * 2 
    brad = pi2 * t / 60.0
    arad = pi2 * t / (12.0 * 60.0)
    bv = [B * math.cos(brad), B * math.sin(brad)]
    av = [A * math.cos(arad), A * math.sin(arad)]
    ans = math.sqrt((bv[0] - av[0])**2 + (bv[1] - av[1])**2)
    return "%.10f" % ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
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)

Solution (Python):
import math

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

a_angle = math.pi * 2 * (h / 12 + m / (60 * 12))
b_angle = math.pi * 2 * (m / 60)

ans = math.sqrt(pow(a,2) + pow(b,2) - (2 * a * b * math.cos(abs(a_angle - b_angle))))

print(ans)

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

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

rad = pi * abs(30 * h - 5.5 * m) / 180

print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(rad)))

Solution (Python):
A,B,H,M= map(int,input().split())
import numpy as np
h = (60*H)+M
kakudo = abs(0.5*h - 6*h)%360
kakudo = np.radians(kakudo)
C =( A**2+B**2-2*A*B*np.cos(kakudo))**0.5
print(C)

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

md = (M % 60) * 6 
hd = (H % 12) * 30 + M * 0.5 

cos2 = np.cos((hd - md) * np.pi / 180)

C2 = A**2 + B**2 - 2*A*B*cos2
print(C2**0.5)

Solution (Python):
def resolve():
    import math
    a, b, h, m = map(int, input().split())
    t1 = math.pi * (h / 6 + m / 360)
    t2 = math.pi * m / 30
    print(((a * math.sin(t1) - b * math. sin(t2)) ** 2 +
           (a * math.cos(t1) - b * math.cos(t2)) ** 2) ** 0.5)


if __name__ == '__main__':
    resolve()