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

m_rad = 2 * math.pi * m / 60.
h_rad = 2 * math.pi * (h / 12.) + 2 * math.pi / 12. * (m / 60.)
m_x, m_y = b * math.cos(m_rad), b * math.sin(m_rad)
h_x, h_y = a * math.cos(h_rad), a * math.sin(h_rad)
print(math.sqrt((m_x - h_x)**2 + (m_y - h_y)**2))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
h_rad = math.radians((-h*30)+90-m*0.5)
m_rad = math.radians((-m*6)+90)
hx = math.cos(h_rad) * a
hy = math.sin(h_rad) * a
mx = math.cos(m_rad) * b
my = math.sin(m_rad) * b
ans = math.sqrt((mx-hx)**2+(my-hy)**2)
print(ans)

Solution (Python):
import math
A,B,H,M=map(int,input().split())
a=math.radians(H*30)+math.radians(M/2)
b=math.radians(M*6)
x1=A*math.cos(a)
y1=A*math.sin(a)
x2=B*math.cos(b)
y2=B*math.sin(b)
d=((x1-x2)**2+(y1-y2)**2)**(1/2)
print(d)

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

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

rad_h = (H / 12  + M / 12 / 60 ) * 2 * math.pi
rad_m = M / 60 * 2 * math.pi

res = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(abs(rad_h - rad_m)))
print(res)

Solution (Python):
a,b,h,m=map(int,input().split())
long_t=h*30+(m/60)*30
short_t=m*6
theta=0
if long_t-short_t>=0:
  theta=long_t-short_t
else:
  theta=short_t-long_t
from math import cos,radians
cos_t=cos(radians(theta))


c=a**2+b**2-2*a*b*cos_t
print(c**0.5)

Solution (Python):
import math
import numpy as np

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

TOTAL = 60. * 12


aa = math.radians(((h * 60. + m) / TOTAL ) * 360.)
bb = math.radians(m / 60. * 360.)
ax = a * math.sin(aa)
ay = a * math.cos(aa)
bx = b * math.sin(bb)
by = b * math.cos(bb)

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

Solution (Python):
import math

if __name__ == "__main__":
    A, B, H, M = list(map(int, input().split()))
    s_ang_vel = 0.5
    l_ang_vel = 6
    time = H*60 + M
    theta = abs(s_ang_vel*time%360 - l_ang_vel*time%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())
import math
sitah = 30 * h + 0.5 * m
sitam = 6 * m
sitax = abs(sitah - sitam)
if sitax > 180:
    sitax = 360-sitax
kosain = (math.cos((math.radians(sitax))))
x2 = a**2 + b**2 - 2*a*b*kosain
ans = math.sqrt(x2)
print(ans)

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

long_n = math.radians(h * 30 + 30 * (m / 60))
short_n = math.radians(360 / 60 * m)
 
y1 = a * math.sin(long_n)
x1 = a * math.cos(long_n)
 
y2 = b * math.sin(short_n)
x2 = b * math.cos(short_n)
 
print(math.sqrt((x2 - x1) **2+ (y2 - y1) **2))

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

import math
def resolve():
    A,B,H,M=pin()
    
    a=(60*H+M)/2
    b=(M)*6
    
    c=abs(a-b)
    if c>180:c=360-c
    
    
    cos_c=math.cos(math.radians(c))
    
    
    C2=A**2+B**2-2*A*B*cos_c
    print(math.sqrt(C2))

resolve()

Solution (Python):
import math
A,B,H,M = map(int,input().split())
Minute = 60*H+M
pi = math.pi
long=2*pi*Minute/720
short=2*pi*M/60
if -pi<=long-short<=pi:
    cos = math.cos(long-short)
else:
    cos =math.cos(2*pi - (long-short))
ans = (A**2 + B**2 - 2*A*B*cos)**0.5
print(ans)

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 sys
import math
input = sys.stdin.readline

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


H_theta = 30 *( H + M * (1/60))
M_theta = M * 6
theta = min(abs(H_theta - M_theta), 360 - abs(H_theta - M_theta))
ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(theta)))
print(ans)

Solution (Python):















from math import cos
from math import radians
from math import sqrt

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

m_kakudo = m /60 * 360
h_kakudo = (h*60 + m) / 720 * 360




if abs(m_kakudo - h_kakudo) == 0:
    print(abs(a-b))
    exit()
elif abs(m_kakudo - h_kakudo) == 180:
    print(a+b)
    exit()
elif abs(m_kakudo - h_kakudo) < 180:
    result = sqrt(a**2 + b**2 - 2*a*b*cos(radians(abs(m_kakudo - h_kakudo))))
    print(result)
    exit()
else:
    result = sqrt(a**2 + b**2 - 2*a*b*cos(radians(360 - abs(m_kakudo - h_kakudo))))
    print(result)
    exit()

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

ab = a
ac = b

rad = abs(30 * (h + m / 60) - 6 * m)
cosA = math.cos(math.radians(rad))

bc2 = ab * ab + ac * ac - 2 * ab * ac * cosA

print(math.sqrt(bc2))

Solution (Python):
import math

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

rad = abs((h*60+m)/(60*12) - m/60) * 2 * math.pi

l = math.sqrt((a*math.sin(rad))**2 + (a*math.cos(rad)-b)**2)

print(l)

Solution (Python):
import math

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

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

C=math.sqrt(A**2+B**2-2*A*B*math.cos(abs(H-M)))
print(C)

Solution (Python):
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)


inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

import math
from collections import deque, defaultdict
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))



def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():
    A, B, H, M = wi()
    r = abs(0.5*(H*60+M) - 6*M)
    t = 360 - r
    y = min(r, t)
    
    x = math.radians(y)
    
    c = A**2 + B**2 - 2 * A * B * math.cos(x)
    print(math.sqrt(c))


if __name__ == '__main__':
    main()

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

Solution (Python):
import math
a = list(map(int, input().split()))
v1 = 360/720
v2 = 360/60
s = a[2] * 60 + a[3]
a1 = v1 *s
a2 = v2 *a[3]
c = abs(a1-a2)
c = c if c<180 else 360-c
l = a[0] **2 + a[1] ** 2 - 2* a[0]*a[1]*math.cos(c/180*math.pi)
print(l ** 0.5)

Solution (Python):
import math

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

s = 360 * (m / 60)
l = 360 * ((60 * h + m) / 720)

theta = math.fabs(s - l)

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

print(ans)

Solution (Python):
import math

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

ra = 360 / 60 * m
rb = 360 / 12 * h + 360 / 12 * m / 60
r = abs(ra-rb)

ans = math.sqrt(math.pow(a,2) + math.pow(b,2) 
                - 2 * a * b * math.cos(math.radians(r)))

print(ans)

Solution (Python):
import math
def main():
    a,b,h,m = tuple([int(t)for t in input().split()])

    radh = 2*math.pi/12*h+2*math.pi/720*m
    radm = 2*math.pi/60*m
    rad = abs(radh-radm)
    rad = min(rad,2*math.pi-rad)


    ans2 = a**2+b**2-2*a*b*math.cos(rad)
    print(ans2**0.5)

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
kaku = abs(a-b)
if kaku > 180:
    kaku = 360-kaku


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

Solution (Python):
import math

A, B, H, M = map(int, input().split())
h = H * 30 + M / 2
m = M * 6
sita = min(abs(h - m), 360 - abs(h - m))
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(sita))))

Solution (Python):
import math

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

dig_hun = 6
dig_ji = 0.5

ji = H * 30 + M * 0.5
hun = 6 * M
dig = abs(ji - hun)
rad = math.radians(dig)
ans = ( A**2 + B**2 - 2 * A * B * math.cos(rad)) ** (1/2)

print(ans)

Solution (Python):
import math
def main():
  num = list(map(int,input().split()))
  a = num[0]
  b = num[1]
  h = num[2]
  m = num[3]
  if((30*h+0.5*m)-(6*m)>0):
    deg=(30*h+0.5*m)-(6*m)
  else:
    deg=(6*m)-(30*h+0.5*m)
  ans=(a*a)+(b*b)-2*a*b*math.cos(math.radians(deg))
  print(math.sqrt(ans))
  
main()

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from math import cos, sqrt, radians

a, b, h, m = na()

al = h * 30 + m * 0.5
bl = m * 6
c = abs(360 - (al - bl))

ans = sqrt(a ** 2 + b ** 2 - (2 * a * b * cos(radians(c))))
print("{:.15f}".format(ans))

Solution (Python):
import math

A,B,H,M=map(int,input().split(" "))
time_in_mins=H*60+M
time_in_hours=H+M/60
angle=0
angle_of_hour=time_in_hours*30
angle_of_min=time_in_mins*6
while angle_of_hour>360:
    angle_of_hour=angle_of_hour-360
while angle_of_min>360:
    angle_of_min=angle_of_min-360
if abs(angle_of_min-angle_of_hour)>=180:
    angle=360-abs(angle_of_min-angle_of_hour)
else:
    angle=abs(angle_of_min-angle_of_hour)
a_2=A*A
b_2=B*B
a_b=A*B
angle_revised=angle*(math.pi)/180
C=math.sqrt(a_2+b_2-2*a_b*(math.cos(angle_revised)))
print(C)

Solution (Python):
def calcAngle(h,m): 
		if (h == 12): 
			h = 0
		if (m == 60): 
			m = 0
		hour_angle = 0.500000000 * (h * 60 + m) 
		minute_angle = 6 * m 
		angle = abs(hour_angle - minute_angle) 
		angle = min(360 - angle, angle) 
		return angle 
import math as mt 
def cal_cos(n): 
    accuracy = 0.0000000001
    x1, denominator, cosx, cosval = 0, 0, 0, 0
    n = n * (mt.pi / 180.000000000) 
    x1 = 1
    cosx = x1 
    cosval = mt.cos(n) 
    i = 1
    while (accuracy <= abs(cosval - cosx)): 
        denominator = 2 * i * (2 * i - 1) 
        x1 = -x1 * n * n / denominator 
        cosx = cosx + x1 
        i = i + 1
    return cosx 
def third_side(a, b, c): 
    angle = cal_cos(c) 
    return mt.sqrt((a * a) + (b * b) - 2 * a * b * angle) 
a,b,h,m=map(int, input().split()) 
ang=calcAngle(h,m)
ts=third_side(a,b,ang)
print(ts)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
A_rad_std = 0.5
B_rad_std = 6
minute = H*60 + M
A_rad = math.radians(A_rad_std * minute)
B_rad = math.radians(B_rad_std * M)

A_Xpoint = A * math.cos(A_rad)
A_Ypoint = A * math.sin(A_rad)
B_Xpoint = B * math.cos(B_rad)
B_Ypoint = B * math.sin(B_rad)

d = math.sqrt((A_Xpoint - B_Xpoint)**2 + (A_Ypoint - B_Ypoint)**2)
print(d)

Solution (Python):
import math

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

Ar = ((2 * math.pi) * (60 * H + M)) / 720
Br = ((2 * math.pi) * M) /60
C = abs(math.pi - (Ar - Br))

D = math.sqrt(((A + (math.cos(C) * B)) ** 2) + (math.sin(C) * B) ** 2)

print(D)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
rh = (h * 60 + m) / 720 * 2 * math.pi
rm = m / 60 * 2 * math.pi
if abs(rh - rm) < 180:
    r = abs(rh - rm)
    c = ((a ** 2) + (b ** 2) - (2 * a * b * math.cos(r))) ** 0.5
    print(c)
if abs(rh - rm) > 180:
    r = 360 - abs(rh - rm)
    c = ((a ** 2) + (b ** 2) - (2 * a * b * math.cos(r))) ** 0.5
    print(c)
if abs(rh - rm) == 180:
    print(a + b)

Solution (Python):
from math import sin, cos, sqrt, radians
A, B, H, M = map(int, input().split())
tan = [0, A]
tyou = [0, B]
tan_angle = H * 30 + 0.5 * M
tyou_angle = M * 6
tan = [A*sin(radians(tan_angle)), A*cos(radians(tan_angle))]
tyou = [B*sin(radians(tyou_angle)), B*cos(radians(tyou_angle))]
print(sqrt((tan[0]-tyou[0])**2 + (tan[1]-tyou[1])**2))

Solution (Python):
import math
A, B, H, M = map(int,open(0).read().split())
jishin = 30 * H + 0.5 * M
hunshin = M * 6
kakuAB = jishin - hunshin
kakuAB = math.radians(kakuAB)
C = abs(A**2 + B**2 - 2*A*B*math.cos(kakuAB)) ** 0.5
print(C)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
l=(360*H/12+360/12*M/60+90)%360
s=(360*M/60+90)%360
xA=math.cos(math.radians(l))*A
yA=math.sin(math.radians(l))*A
xB=math.cos(math.radians(s))*B
yB=math.sin(math.radians(s))*B
d=math.sqrt((xB-xA)**2+(yB-yA)**2)
print(d)

Solution (Python):
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, H, M = mapint_inp()



def get_hour_hand_angle(h, m):
    return (h*30)+(0.5*m)

def get_minute_hand_angle(m):
    return 6*m


def get_formed_angle(hour_hand_angle, minute_hand_angle):
    diff = abs(hour_hand_angle - minute_hand_angle)
    if diff > 180:
        return 360 - diff
    return diff



import math

def get_ans():
    hha = get_hour_hand_angle(H,M)
    mha = get_minute_hand_angle(M)
    fa = get_formed_angle(hha, mha)
    c = math.cos(math.radians(fa))
    return math.sqrt((A**2)+(B**2)-(2*A*B*c))


print(get_ans())

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

s = 60 * H + M
r1 = 2 * math.pi * s / 720
r2 = 2 * math.pi * M / 60

r = abs(r1 - r2)
r = min (r, 2 * math.pi - r)

print( (A * A + B * B - 2 * A * B *math.cos(r)) ** 0.5)

Solution (Python):
import sys
import math
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

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

degree = abs(h*30+30*(m/60) - m*6)
degree = min(degree,360-degree)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(degree))))

Solution (Python):
import math

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

theta_b = 360*m/60
theta_a = 30*(h+m/60)
theta = abs(theta_a-theta_b)

if theta > 180:
    theta = 360 - theta

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

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

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

Solution (Python):
import math

def main():
  A, B, H, M = map(int, input().split())
  A_angle_from_12 = 30*H + M/2
  A_angle = 90 + A_angle_from_12
  B_angle_from_12 = 6*M
  B_angle = 90 + B_angle_from_12
  
  A_x = A * math.cos(math.radians(A_angle))
  A_y = A * math.sin(math.radians(A_angle))
  B_x = B * math.cos(math.radians(B_angle))
  B_y = B * math.sin(math.radians(B_angle))

  res = math.sqrt((A_x - B_x)**2 + (A_y - B_y)**2)
  print(res)

if __name__ == "__main__":
    main()

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

resolve()

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

time = H*60 + M
Arad = (M%60) * 2*math.pi/60
Brad = time * 2*math.pi/720

h = ((A*math.cos(Arad) - B*math.cos(Brad))**2 + (A*math.sin(Arad) - B*math.sin(Brad))**2)**0.5
print(h)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
radA = (360 // 12) * h + 30 * (m / 60)
radB = (360 // 60) * m
radAB = abs(radA - radB)
radAB = radAB / 180 * math.pi
c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(radAB)
print(math.sqrt(c2))

Solution (Python):
a,b,h,m = map(int,input().split())
t = 60 * h + m
aa = t / 360
bb = t / 30
import math
if aa >= bb:
    θ = (aa - bb)
else:
    θ = (bb - aa)
theta1 = θ * math.pi
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta1))
print(c)

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

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

Solution (Python):
import math
pi = math.pi
A = [int(n) for n in input().split()]
print((A[0]**2 + A[1]**2 - 2*A[0]*A[1]*math.cos(math.radians(A[3]*11/2 - A[2]*30))) ** (1/2))

Solution (Python):
import math
a, b, h, m = map(float, input().split())
h = h * 60 + m
ra = h * 0.5
rb = m * 6
rc = max(ra, rb) - min(ra, rb)

if rc > 180.0:
	rc = 360.0 - rc

if rc == 180.0:
	ans = a + b
else:
	ans = a**2 + b**2 - 2 * a* b * math.cos(math.radians(rc))
	ans = math.sqrt(ans)

print(ans)

Solution (Python):
import math

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

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

import math

deg_m_hand = 360*(H/12) + 30*(M/60)
deg_h_hand = 360*(M/60)

theta = deg_m_hand - deg_h_hand

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

print(AB)

Solution (Python):
import math
a,b,h,m = map(int,input().split())
def l(x,y,th):
    return math.sqrt(x*x+y*y - 2*x*y*math.cos(math.radians(th)))
def sita(h,m):
    a = 30*h+0.5*m
    b = 6*m
    if a > 180 and b < 180:
        a =360-a
        return a + b
    elif a < 180 and b > 180:
        b = 360-b
        return a + b
    else:
        if a > b:
            return a-b
        else:
            return b-a
print(l(a,b,sita(h,m)))

Solution (Python):
import math

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

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

deg =abs(m - h)

ab2 = a**2 + b**2 -2*a*b*math.cos(math.radians(deg))
ab = ab2**0.5

print(ab)

Solution (Python):
import math
A,B,H,M=map(int,input().split())
a=((H+M/60)/12)*2
b=(M/60)*2
if a-b<=1:
  omega=a-b
else:
  omega=2-(a-b)
print((A**2+B**2-2*A*B*math.cos(omega*math.pi))**(1/2))

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

x1 = A * cos(radians(30 * H + M / 2))
y1 = A * sin(radians(30 * H + M / 2))

x2 = B * cos(radians(6 * M))
y2 = B * sin(radians(6 * M))

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

Solution (Python):
import math

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

A_rad = (math.pi/6)*(H+(M/60))
B_rad = (math.pi/30)*M

rad = max(A_rad, B_rad) - min(A_rad, B_rad)

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

print(d)

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

hun = H*60 + M
zisin = hun * 0.5
hunsin = hun * 6
kakusa = (hunsin - zisin) % 360

if kakusa >= 180:
    kakusa = 360 - kakusa

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

print(ans)

Solution (Python):
import sys
import math
input = sys.stdin.readline
A, B, H, M = map(int, input().split())
theta = (H / 12) * 360 + (M / 60) * 30 - (M / 60) * 360
res = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(theta)))
print(res)

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

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

long = 360 * h / 12 + 360 / 12 * m / 60
short = 360 * m / 60


if True:
    theta = abs(long - short) * math.pi / 180
    B = a * math.cos(theta) - b
    A = a * math.sin(theta)
    print(math.sqrt(A*A + B*B))

Solution (Python):
import math
x=input()
x0=x.split()
a=int(x0[0])
b=int(x0[1])
h=int(x0[2])
m=int(x0[3])
t1=float(math.pi*(h*60+m)/360)
t2=float(math.pi*m/30)
answer=math.sqrt((a*math.cos(t1)-b*math.cos(t2))**2+(a*math.sin(t1)-b*math.sin(t2))**2)
print(answer)

Solution (Python):
import math
a,b,h,m= list(map(int,input().split()))
x = h*60 + m 

theta_s = 0.5*x
theta_s = theta_s % 360
theta_l = 6.0*x
theta_l = theta_l % 360
theta_mean = abs(theta_l-theta_s)

if theta_mean > 180:
    theta_mean = 360 - theta_mean
c2 = a**2 + b**2 - 2*a*b*math.cos(theta_mean*math.pi/180) 
c = math.sqrt(c2)
print(c)

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

import math

time = H*60 + M
dist = (5.5 * time)%360
if 0 < dist < 180:
   dist = 360 - dist

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

print(ans)

Solution (Python):
import math

line=input().split()
line=[int(i) for i in line]
time=line[2]*60+line[3]
xhour=line[0]*math.cos((2*math.pi*time)/720)
yhour=line[0]*math.sin((2*math.pi*time)/720)
xmin=line[1]*math.cos((2*math.pi*time)/60)
ymin=line[1]*math.sin((2*math.pi*time)/60)
ans=math.sqrt(((xhour-xmin)**2)+((yhour-ymin)**2))
print(ans)

Solution (Python):
import math

def output(A,B,ang):
    return (A**2 + B**2 - 2 * A * B * math.cos(ang)) ** (1/2)

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

H_ang = H / 12 * 2 * math.pi + M / 60 * math.pi / 6
M_ang = M / 60 * 2 * math.pi
if abs(H_ang-M_ang) > math.pi:
    ang = math.pi * 2 - abs(H_ang - M_ang)
else:
    ang = abs(H_ang - M_ang)

print(output(A,B,ang))

Solution (Python):
def main():
    import math
    a,b,h,m=map(int, input().split())
    p=math.pi
    ang_h,ang_m=h*p/6+m*p/360,m*p/30
    ang=abs(ang_h-ang_m)
    if ang<p:
        ans=a**2+b**2-2*a*b*math.cos(ang)
        print(math.sqrt(ans))
    else:
        ans=a**2+b**2-2*a*b*math.cos((2*p-ang))
        print(math.sqrt(ans))

if __name__=='__main__':
    main()

Solution (Python):
import math
A, B, H, M= map(int, input().split())
hour_angle = 30 * H + 0.5 * M
minu_angle = 6 * M
min_angle = min(hour_angle, minu_angle)
max_angle = max(hour_angle, minu_angle)
dif_num = max_angle - min_angle
answer1 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(dif_num))
answer2 = math.sqrt(answer1)
print(answer2)

Solution (Python):
import numpy as np

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







hour = np.array([a*np.cos(np.radians(90)-(np.radians(30*h)+np.radians(0.5*m))), a*np.sin(np.radians(90)-(np.radians(30*h)+np.radians(0.5*m)))])

minute = np.array([b*np.cos(np.radians(90)-(np.radians(6*m))), b*np.sin(np.radians(90)-(np.radians(6*m)))])

diff = hour - minute

print(np.linalg.norm(diff))

Solution (Python):
import math
A,B,H,M=map(int,input().split())
s=30*H+M/2
l=6*M
D=max(l,s)-min(l,s)
ans=(A**2+B**2-2*A*B*math.cos(D*math.pi/180))**0.5
print(ans)

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

h_degree = 30 * (H % 12 + M / 60)
m_degree = M * 6


dif_degree = abs(h_degree - m_degree)
if dif_degree >= 180:
    degree = 360 - dif_degree
else:
    degree = dif_degree

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

Solution (Python):
import math

A,B,H,M = map(int,input().split())
h = 0.5*(H*60+M)
m = 6*M
t = abs(h-m)
if t > 180:
    t = 360 - t

if t <= 90:
    p = math.cos(math.radians(t))*B - A
    q = math.sin(math.radians(t))*B
    print((p**2+q**2)**0.5)
else:
    p = math.cos(math.radians(180-t))*B+A
    q = math.sin(math.radians(180-t))*B
    print((p**2+q**2)**0.5)

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

    minite = h*60 + m
    degmin = math.radians(90 - 6 * minite)
    deghour = math.radians(90 - 0.5 * minite)

    pointmin = [b * math.cos(degmin), b * math.sin(degmin)]
    pointlong = [a * math.cos(deghour), a * math.sin(deghour)]

    print(math.sqrt((pointmin[0] - pointlong[0])**2 + (pointmin[1] - pointlong[1])**2))
 
 

resolve()

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

min=6*m

max=30*h+0.5*m

degree=max-min

cos=math.cos(math.radians(degree))

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

print(ans)

Solution (Python):
import math 
a,b,h,m=map(int, input().split())
p=360*(h/12+m/(12*60))
q=360*(m/60)
if(p>=q):
    r=p-q
else:
    r=q-p
if(r>180):
    r=360-r

rad=math.radians(r)
cos=math.cos(rad)
c=a*a+b*b-2*a*b*cos
c2=math.sqrt(c)

print(f"{c2:.10f}")

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

def hourToMin(hour,minu):
  out = hour + (minu/60)
  return out*5
 
H = hourToMin(H,M)  
dif =  H-M
cos = math.cos(math.radians(dif*6))
ans = (A**2+B**2-2*A*B*cos)**0.5

print(ans)

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

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

h = (H + M/60)/ 12 * 2 * pi
m = M / 60 * 2 * pi
print(sqrt((A * sin(h) - B * sin(m)) ** 2 + (A * cos(h) - B * cos(m)) ** 2))

Solution (Python):
import math

def main():
    a,b,h,m = map(int, input().split())
    l_hand = 6 * m
    s_hand = 30 * h + m / 2
    theta = abs(l_hand - s_hand)

    if theta > 180:
        theta = 360 - theta
    
    cos_theta = math.cos(math.radians(theta))
    
    ans = a ** 2 + b ** 2 - 2 * a * b * cos_theta
    print(math.sqrt(ans))

if __name__ == "__main__":
    main()

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

Solution (Python):
import math
A, B, H, M = (int(x) for x in input().split())
theta = abs(6 * ((H*60 + M)/12 - M))
if theta > 180:
    theta = 360 - theta
x = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta)))
print(x)

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


def main():
    short, loong, h, m = map(int, input().split())
    long_rad = math.radians(360 * m / 60)
    short_rad = math.radians(360 * h / 12 + (30 * m / 60))

    long_x = loong * math.cos(long_rad)
    long_y = loong * math.sin(long_rad)
    short_x = short * math.cos(short_rad)
    short_y = short * math.sin(short_rad)
    ans = math.sqrt((long_x - short_x) ** 2 + (long_y - short_y) ** 2)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math
from decimal import Decimal

a, b, h, m = map(int, input().split())
lon = 0.5 * m + 30 * h
sho = 6 * m
d = max(lon, sho) - min(lon, sho)
deg = min(d, abs(360-d))

f = lambda c: c if c <= 90 else 180 - c
rad = math.radians(f(deg))
y = Decimal(math.sin(rad))
x = Decimal(math.cos(rad))
if deg > 90:
    L = a + x * b
else:
    L = a - x * b
l = b * y

print("{:.9f}".format(Decimal(math.sqrt((l**2)+(L**2)))))

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

d_kaku=6*d
c_kaku=30*(c+(d/60))
c_d=abs(d_kaku-c_kaku)

if c_d==180:
    e=a+b
    print(e)
elif c_d==0 or c_d==360:
    print(abs(a-b))
elif c_d<180:

    e=math.cos(math.radians(c_d))
    f2=a*a+b*b-2*a*b*e
    print(math.sqrt(f2))

else:
    e=math.cos(math.radians(360-c_d))

    f2=a*a+b*b-2*a*b*e
    print(float(math.sqrt(f2)))

Solution (Python):
import math
A, B, H, M = map(int, input().split())
X = (H*30+M*0.5)
Y = M*6
Z = 360-abs(X-Y)
E = math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(Z)))
print(E)

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

deg1 = 30 * h + 0.5*m
deg2 = 6*m
deg3 = deg2 - deg1
ans = a**2 + b**2 - (2*a*b*math.cos(math.radians(deg3)))
print(ans**0.5)

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

a_angle = 360*H/12 + 15*2*M/60
b_angle = 360*M/60

angle = a_angle - b_angle
if angle>180:
    angle = 360 - angle

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
kaku = abs(6*m-30*h-0.5*m)
if kaku >= 180:
    kaku = 360 - kaku

cos = math.cos(kaku*math.pi/180)

tmp = a**2+b**2-2*a*b*cos

print(math.sqrt(tmp))

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

[A,B,H,M] = [ int(x) for x in input().split() ]
aAngle = (H%12 + M/60.0) / 12.0 * 2*pi
bAngle = M%60 / 60.0 * 2*pi
angle = max(aAngle,bAngle) - min(aAngle, bAngle)
ans = A**2 + B**2 - 2*A*B*cos(angle)
ans = sqrt(ans)
print(ans)

Solution (Python):
import math
a,b,h,m = map(int, input().split())
ah = ((60*h+m) / (12*60)) * 360
am = (m / 60) * 360

def cal_pos(r, a):
    x = 1
    y = 1
    if a <= 90:
        a_use = a
    elif a <= 180:
        a_use = 180 - a
        y *= -1
    elif a <= 270:
        a_use = a - 180
        x *= -1
        y *= -1
    else:
        a_use = 360 - a
        x *= -1
        
    yl = (r**2 / (math.tan(a_use/180*math.pi)**2 + 1)) ** 0.5
    xl = yl * math.tan(a_use/180*math.pi)
    x *= xl
    y *= yl
    return x,y

pos_h = cal_pos(a,ah)
pos_m = cal_pos(b,am)
dis = ((pos_h[0] - pos_m[0])**2 + (pos_h[1] - pos_m[1])**2)**0.5
print(dis)

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

angle = abs(30 * h - 5.5 * m)

if angle >= 180:
    angle = 360 - angle

angle = math.radians(angle)

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

print('{:.020f}'.format(ans))

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

import math
h = h % 12
m = m % 60
theta = m / 60 * 2 * math.pi
theta2 = (h / 12 + m / 12 / 60) * 2 * math.pi


sa = abs(theta - theta2)

if sa >= math.pi:
    sa = 2 * math.pi - sa

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