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

long = H * 30 + M * 0.5
short = M * 6
angle = abs(long-short)
if angle > 180:
  angle = 360 - angle
  
ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(angle))
ans = (ans) ** (1/2)
print(ans)

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

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

import math

_long = 2 * math.pi * (((60 * h) + m) / 720)
short = 2 * math.pi * (m/60)
diff = abs(_long - short)
if diff > math.pi:
    diff = 2 * math.pi - diff
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(diff)))

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

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

long_hand_angle = M * 6
short_hand_angle = (H * 60 + M) * 0.5
theta = abs(long_hand_angle - short_hand_angle)
theta = min(theta, 360 - theta)

C = sqrt(A**2 + B**2 - 2 * A * B * cos(radians(theta)))
print(C)

Solution (Python):
import math

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

rad_A =  (360 * H/12 + 30 * M/60) % 360
rad_B = 360 * M/60
rad_diff = max(rad_A, rad_B) - min(rad_A, rad_B)
rad_diff = min(rad_diff, 360 - rad_diff)

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


print(ans)

Solution (Python):

import math
def q3():
    A, B, H, M = [int(i) for i in input().split(" ")]

    def get_pos(l, deg):
        x = l * math.cos(math.radians(deg))
        y = l * math.sin(math.radians(deg))
        return [x, y]

    def get_distance(pos1, pos2):
        return math.sqrt(
            math.pow(pos1[0] - pos2[0], 2) +
            math.pow(pos1[1] - pos2[1], 2)
        )

    pos_h = get_pos(A, 90 - ((H + M / 60) / 12) * 360)
    pos_m = get_pos(B, 90 - (M / 60) * 360)

    d = get_distance(pos_h, pos_m)
    print(d)

q3()

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

a,b,h,m=map(int,input().split())
tax=a*cos(pi/2 - (h/12+m/60/12)*2*pi)
tay=a*sin(pi/2 - (h/12+m/60/12)*2*pi)
tbx=b*cos(pi/2 - (m/60)*2*pi)
tby=b*sin(pi/2 - (m/60)*2*pi)

print( ((tax - tbx)**2 + (tay - tby)**2) ** .5)

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

import math

H_tmp = 2*math.pi*(H/12) + (2*math.pi/12)*(M/60)
M_tmp = 2*math.pi*(M/60)

kakudo = min(abs(H_tmp-M_tmp),2*math.pi - abs(H_tmp-M_tmp))

ans = (A**2 + B**2 - 2*A*B*math.cos(kakudo))**0.5

print(ans)

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

Solution (Python):
import math
A,B,H,M =map(int, input().split())
s1 = math.radians(30*H + 0.5*M)
s2 = math.radians(6*M)
x1 = A* math.cos(s1)
y1 = A* math.sin(s1)
x2 = B* math.cos(s2)
y2 = B* math.sin(s2)
L = ((x1-x2)**2 + (y1-y2)**2)**0.5
print(L)

Solution (Python):
import math

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

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

angle_M = M * m
angle_H = (H * 60 + M) * h

angle = math.fabs(angle_M - angle_H)

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

print(length)

Solution (Python):
from collections import deque
from collections import defaultdict
import math



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

speed1 = 360/(12*60)
speed2 = 360/(60)
time = h*60 + m

k1 = speed1 * time
k2 = speed2 * time

kakudo = min(abs(k1-k2), 360-abs(k1-k2))

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

Solution (Python):
import math

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

kaku = math.pi / 360 * abs(60 * h - 11 * m)


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

print(ans ** (1 / 2))

Solution (Python):

import math
PI = math.pi

a, b, h, m = map(int, input().split())
x1 = a * math.cos((PI/2) - 2*PI*(60*h+m)/720)
y1 = a * math.sin((PI/2) - 2*PI*(60*h+m)/720)
x2 = b * math.cos((PI/2) -2*PI*m/60)
y2 = b * math.sin((PI/2) -2*PI*m/60)


print(((x2-x1)**2 + (y2-y1)**2)**.5)

Solution (Python):
import math

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

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

ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(abs(30*h - 11/2*m))))**(1/2)

print(ans)

Solution (Python):
import math


Ar, Br, H, M = map(int, input().split())
Ht = math.pi * (H / 6) + math.pi * (M / 360)
Mt = math.pi * (M / 30)
Ax =  Ar * math.cos(Ht)
Ay = Ar * math.sin(Ht)

Bx =  Br * math.cos(Mt)
By = Br * math.sin(Mt)





print(math.sqrt((Ax-Bx) ** 2 + (Ay-By)**2))

Solution (Python):
import math
A,B,H,M=map(int,input().split())
T=(60*H)+M
a=(6*T)%360
b=(0.5*T)
if a==b:
  print(abs(A-B))
  exit()

x=(A**2)+(B**2)-(2*A*B*math.cos(math.radians(abs(a-b))))
print(math.sqrt(x))

Solution (Python):
import math


inputs = input().split(' ')
a,b = int(inputs[0]), int(inputs[1])
h,m = int(inputs[2]), int(inputs[3])

h *= 30
h += m/2
m *= 6

a1 = a * math.sin(math.radians(h))
a2 = a * math.cos(math.radians(h))
b1 = b * math.sin(math.radians(m))
b2 = b * math.cos(math.radians(m))

print(math.sqrt((a1 - b1)**2 + (a2 - b2)**2))

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

ans = abs(rect(A, (H + M / 60) / 12 * 2 * pi) - rect(B, M * 2 * pi / 60))
print(ans)

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

x_shorthand=A*math.cos(math.pi*(H+M/60)/6)
y_shorthand=A*math.sin(math.pi*(H+M/60)/6)

x_longhand=B*math.cos(math.pi*(H*60+M)/30)
y_longhand=B*math.sin(math.pi*(H*60+M)/30)

print(math.sqrt((x_shorthand-x_longhand)**2+(y_shorthand-y_longhand)**2))

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

s = 2.0*math.pi*(60.0*h+m)/720.0
t = 2.0*math.pi*m/60.0
print(math.sqrt((a*math.cos(s)-b*math.cos(t))**2+(a*math.sin(s)-b*math.sin(t))**2))

Solution (Python):
import math
import sys
import bisect
import heapq  

inf = 10 ** 15
mod = 10 ** 9 + 7
a,b,h,m = map(int, input().split())
p = math.pi

arg = 2*p*(h/12)
arg = arg-11/360*p*m
arg = min(abs(arg), 2*p-abs(arg))
xx = a*a+b*b-2*a*b*math.cos(arg)
print(math.sqrt(xx))

Solution (Python):
import math

A,B,H,M=map(int,input().split())
sital=30*H+0.5*M
sitas=6*M
sita=min(abs(sital-sitas),360-abs(sital-sitas))
co=math.cos(math.radians(sita))
L=A*A+B*B-2*A*B*co
l=L**0.5
print(l)

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


dx = a*math.sin(2*PI*h/12 + 2*PI*m/12/60) - b*math.sin(2*PI*m/60)
dy = a*math.cos(2*PI*h/12 + 2*PI*m/12/60) - b*math.cos(2*PI*m/60)
print((dx**2 + dy**2)**(0.5))

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

theta = 2 * math.pi * abs(M / 60 - (H+M/60) / 12)

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

print(ans)

Solution (Python):
import math

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

rad_H = (H+(M/60)) / 6 * math.pi
rad_M = M / 30 * math.pi

rad = abs(rad_H - rad_M)
print(math.sqrt(A**2 + B **2 - 2 * A * B * math.cos(rad)))

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


import numpy as np

a,b,h,m = mi()
h2 = h + m/60

ax = a * np.cos(h2/12 * 2*np.pi)
ay = a * np.sin(h2/12 * 2*np.pi)
bx = b * np.cos(m/60 * 2*np.pi)
by = b * np.sin(m/60 * 2*np.pi)


dist = np.sqrt((ax-bx)**2 + (ay-by)**2)

print(dist)

Solution (Python):
import math
import numpy

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

hun = h * 60 + m

p = numpy.array([a*math.cos(hun*math.pi/30), a*math.sin(hun*math.pi/30)])
q = numpy.array([b*math.cos(hun*math.pi/360), b*math.sin(hun*math.pi/360)])
u = p-q

print(numpy.linalg.norm(u))

Solution (Python):
from math import pi,cos
def solve():
    ans = 0
    A, B, H, M = map(int, input().split())
    theta = ((30*H-5.5*M)%360)*pi/180
    ans = (A**2+B**2-2*A*B*cos(theta))**0.5
    return ans
print(solve())

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

kakudo = min(abs(M*6 - (H*60 + M)*0.5),360-abs(M*6 - (H*60 + M)*0.5))

ans = (A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudo)))**(1/2)

print(ans)

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, h, m = list(map(int, readline().split()))
    deg_a = 30 * h + (m / 60) * 30
    deg_b = 6 * m
    if deg_a > deg_b:
        deg = deg_a - deg_b
    else:
        deg = deg_b - deg_a
    import math
    if deg > 180:
        deg = 360 - deg

    c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(deg))
    print(c2 ** 0.5)


if __name__ == '__main__':
    main()

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

Hang = H * 30 + 30 * M / 60 
Mang = M * 6 

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

print(ans)

Solution (Python):





import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string


BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def main():
    abhm=list(map(int,input().split()))
    a,b,h,m=abhm[0],abhm[1],abhm[2],abhm[3]
    x=abs(h*30+m*30/60-m*6)
    if x>=180:
        x=360-x
    
    
    res=a*a+b*b-2*b*a*math.cos(math.radians(x))
    print (math.sqrt(res))
if __name__ == "__main__":
    main()

Solution (Python):


from math import cos, pi

def main(A, B, H, M):
    theta_b = M / 60 * (2 * pi)
    theta_a = 1 / 12 * (H + M / 60) * (2 * pi)
    AB = (A ** 2 + B ** 2 - 2 * A * B * cos(theta_a - theta_b)) ** 0.5
    print(AB)

if __name__ == '__main__':
    A, B, H, M = map(int, input().split())
    main(A, B, H, M)

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

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

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

d = 60*H - 11*M
t = d / 360 * math.pi

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

Solution (Python):
import math

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



Arad = math.radians((H/12+M/720)*360)
Brad = math.radians((M/60)*360)

C = A**2 + B**2 - 2*B*A*math.cos(Brad-Arad)

print(C**(1/2))

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

Solution (Python):
import math

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

theta=(H*30+0.5*M)-M*6

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

C=CC**(1/2)

print(format(C, '.11f'))

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

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

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

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

def resolve():
    a,b,h,m = map(int,input().split())
    hh = (h / 12 + m / 60 / 12) * 360
    mm = m / 60 * 360

    hbb = (a * cos( radians(hh)), a * sin(radians(hh)))
    mbb = (b * cos( radians(mm)), b * sin(radians(mm)))
    
    print('{:.12f}'.format(sqrt( (hbb[0] - mbb[0])**2 + (hbb[1] - mbb[1])**2)))

if __name__ == "__main__":
    resolve()

Solution (Python):
from math import *

A,B,h,m = map(int,input().split())

if h>11:h-=12
s=l=.0
l=m*6
s=30*(h+(m/60))
if l<s:l,s=s,l
if l-s>180:d=360-l+s
else:d=l-s
c = cos(radians(d))

ans = sqrt(A**2+B**2-2*A*B*c)

print(ans)

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

import math

hd = h * 30
md = (m / 5) * 30
hd += (m / 60) * 30
d = hd-md
d = min(d, abs(360-d))
cs = math.radians(d)
c = math.sqrt(a**2+b**2-2*a*b*math.cos(cs))
print(c)

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
ax = a*math.cos(math.radians(30*h+0.5*m))
ay = a*math.sin(math.radians(30*h+0.5*m))
bx = b*math.cos(math.radians(6*m))
by = b*math.sin(math.radians(6*m))
leng = math.sqrt(((abs(ax-bx))**2+(abs(ay-by))**2))
print(leng)

Solution (Python):
import sys



import math







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

def main():
    a,b,h,m = map(int, stdin.readline().rstrip().split())
    
    
    
    
    
    min = h*60 + m
    long = min * 360 / (60*12)
    short = 360 * m/60
    angle = abs(short-long)
    c2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(angle))
    print(c2 ** 0.5)



main()

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

time = h * 60 + m
h_pos = time * h_v
m_pos = m * m_v

rad = abs(min((min(h_pos, m_pos)+360)-max(h_pos, m_pos), max(h_pos, m_pos)- min(h_pos, m_pos)))
rad = rad / 180 * np.pi

ans = (a**2 + b**2 - 2*a*b*np.cos(rad))**0.5
print(ans)

Solution (Python):
import math

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

radA = (H + (M / 60)) / 12
radB = M / 60

rad = abs(radA - radB) * 2 * math.pi


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

print(X)

Solution (Python):
import math
from typing import NoReturn


def main() -> NoReturn:
    a, b, h, m = map(int, input().split())  

    diag: float = (5.5 * (60 * h + m)) % 360

    if diag == 180:
        print(a + b)
        return
    elif diag > 180:
        diag = 360 - diag

    answer: float = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(diag / 180 * math.pi))
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):

import math

a = list(map(int,input().split()))
A = a[0]
B = a[1]
H = a[2]
M = a[3]


theta = (30.0 * H + 0.5 * M) - (6.0 * M)

if theta > 180:
    theta = 360 - theta

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

print(x)

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

th_a = math.pi / 6 * h + math.pi / 6 * m / 60
th_b = math.pi / 30 * m

l = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(th_a - th_b))

print(l)

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

hour=360*(H/12)+30*((M)/60)
minu=360*(M/60)


deg=min(abs(hour-minu), 360-abs(hour-minu))
if deg==0:
    print(abs(A-B))
    exit()
ans2=A**2+B**2-2*A*B*cos(radians(deg))

print(sqrt(ans2))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
d = math.radians((h * 60 + m) * (6 - 1/2) % 360)

ans = (a ** 2 + b ** 2 - 2 * a * b * math.cos(d)) ** (1/2)
print(ans)

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

x=abs(360-abs(30*H-11/2*M))
anser=math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(x)))
print(anser)

Solution (Python):

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

degA = (30*H+0.5*M)/360*(2*math.pi)
degB = 6*M/360*(2*math.pi)
xa = A*math.cos(degA)
ya = A*math.sin(degA)
xb = B*math.cos(degB)
yb = B*math.sin(degB)
res = ((xa-xb)**2+(ya-yb)**2)**0.5
print(res)

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

h_rad = 360.0 / 60.0 / 12.0
m_rad = 360.0 / 60.0

h_theta = h_rad * ((H%12)*60 + M)
m_theta = m_rad * M

sa_theta = abs(h_theta-m_theta)

a = math.sqrt(A*A + B*B - 2*A*B*math.cos(math.radians(sa_theta)))
print(a)

Solution (Python):
import math

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

AX = A*math.cos(math.pi*(H/6+M/360))
AY = A*math.sin(math.pi*(H/6+M/360))

BX = B*math.cos(M*math.pi/30)
BY = B*math.sin(M*math.pi/30)

print(math.sqrt((AX-BX)**2 + (AY-BY)**2))

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

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

a_th = (pt * 1/12 - int(pt * 1/12)) * 360
b_th = (pt  - int(pt)) * 360

theta = 1000

if a_th > b_th:
    theta = a_th-b_th
    if theta > 180:
        theta = 360 -theta

if a_th <= b_th:
    theta = -a_th+b_th
    if theta > 180:
        theta = 360 -theta




theta = math.radians(theta)


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

print(C)

Solution (Python):
import math

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

h %= 12
short = m*6

long = (h*60+m)/2.0
dif = abs(short-long)
cs=math.radians(dif)
c=math.sqrt(a**2+b**2-2*a*b*math.cos(cs))
print(c)

Solution (Python):



import sys
import math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a, b, H, M = i2nn()
    A_rad = (H + M / 60) / 12
    B_rad = M / 60
    C = (A_rad - B_rad) * math.pi * 2
    c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C))
    print(c)
    return

main()

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


angleB=2*pi*M/60
angleA=2*pi*(H/12+M/12/60)


pointA=[A*cos(angleA),A*sin(angleA)]
pointB=[B*cos(angleB),B*sin(angleB)]

print(sqrt((pointA[0]-pointB[0])**2+(pointA[1]-pointB[1])**2))

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

m=M/60*math.pi*2
h=H/12*math.pi*2+m/12
if m>=h:
    alpha=m-h
else:
    alpha=h-m
ans=pow(B,2)+pow(A,2)-2*B*A*math.cos(alpha)
print(math.sqrt(ans))

Solution (Python):
import math 
A,B,H,M=list(map(int,input().split()))
pi=math.pi
S1=2*pi*(H+(M/60))/12
S2=M*2*pi/60
print(math.sqrt((A*math.cos(S1)-B*math.cos(S2))**2+(A*math.sin(S1)-B*math.sin(S2))**2))

Solution (Python):
import numpy as np
import math

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

time = H + (M / 60.0)
a_rot = (time / 12.0) * np.pi * 2
b_rot = (M / 60.0) * np.pi * 2

rot = a_rot - b_rot
if rot < 0:
    rot = b_rot - a_rot


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

print(ans)

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

import math  

M_length = B  
H_length = A  

nowhour = H+M/60
nowminute=M

H_A = nowhour / 12 * 360 * math.pi /180  
M_A = nowminute / 60 * 360 * math.pi / 180

H_x = math.cos(H_A) * H_length  
H_y = math.sin(H_A) * H_length
M_x = math.cos(M_A) * M_length
M_y = math.sin(M_A) * M_length
ans1=(H_x-M_x)**2+(H_y-M_y)**2
ans2=ans1**(0.5)
print(ans2)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,H,M = II()

H_angle = ((H * 60 + M) * 360) / (12 * 60)
M_angle = (M * 360)/60

angle = abs(H_angle - M_angle)



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

print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
ar=((h+m/60)%12)/12 * math.pi * 2
ax=a*math.sin(ar)
ay=a*math.cos(ar)
br=((h*60+m)%60)/60 * math.pi * 2
bx=b*math.sin(br)
by=b*math.cos(br)
print( ( (ax-bx)**2+(ay-by)**2 )**0.5 )

Solution (Python):
import math

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

    x_2 = (a*math.cos(2*math.pi*(h/12 + m/60/12)) - b*math.cos(2*math.pi*m/60)) ** 2
    y_2 = (a*math.sin(2*math.pi*(h/12 + m/60/12)) - b*math.sin(2*math.pi*m/60)) ** 2
    print((x_2 + y_2)**0.5)


main()

Solution (Python):
import math


def distance(v1, v2, deg):
    left = v1 ** 2 + v2 ** 2
    right = 2 * v1 * v2 * math.cos(math.radians(deg))
    return math.sqrt(left - right)


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

hr = h * 30 + (m / 60) * 30
mr = m * 6

diff = math.fabs(hr - mr)

print(distance(a, b, diff))

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

k_c = abs((m / 60 * 360) - (h / 12 * 360 + m / 60 * 30))

if k_c > 180:
  k_c = 360 - k_c

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
jx = a*math.sin((h/12+m/(60*12))*2*math.pi)
jy = a*math.cos((h/12+m/(60*12))*2*math.pi)
hx = b*math.sin(m/60*2*math.pi)
hy = b*math.cos(m/60*2*math.pi)



ans = (jx-hx)**2 + (jy-hy)**2
print(ans**(1/2))

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

Hrad = 2 * pi * (60 * H + M) / 720
Mrad = 2 * pi * M / 60

drad = abs(Hrad-Mrad)
d = np.sqrt(A**2+B**2-2*A*B*np.cos(drad))
print(d)

Solution (Python):
import math

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

longdeg = (2 * math.pi) / 12 * (H + M/60)
shortdeg = (2 * math.pi) * M / 60

deg = abs(longdeg - shortdeg)

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

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

Solution (Python):

import math

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

th1=(30*h+0.5*m)/180*math.pi
th2=6*m/180*math.pi

ax=a*math.sin(th1)
ay=a*math.cos(th1)
bx=b*math.sin(th2)
by=b*math.cos(th2)

d=((ax-bx)**2+(ay-by)**2)**0.5
print(d)

Solution (Python):
from math import pi,cos,sqrt
A,B,H,M = map(int,input().split())
m = M/60
h = (H*60+M)/720
d = abs(m-h)
c = cos(d*2*pi)
ans = sqrt(A**2 + B**2 - 2*A*B*c)
print(ans)

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

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

import numpy as np

HS = 360/720
MS = 360/60
deg = ((H*60+M)*HS)%360-(MS*M)
print(np.sqrt(A**2+B**2-2*A*B*np.cos(np.radians(deg))))

Solution (Python):
import math

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

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

angle_M = M * m
angle_H = (H * 60 + M) * h

angle = math.fabs(angle_M - angle_H)

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

print(length)

Solution (Python):
from math import sqrt, cos, radians
a, b, h, m = map(int, input().split())
x = h * 30
if m != 0:
    x += 30 / (60 / m)
y = m * 6
c = min(abs(x - y), 360 - abs(x - y))

print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(radians(c))))

Solution (Python):
import math

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

mk=m/60*360
mkx=b*math.sin(math.radians(mk))
mky=b*math.cos(math.radians(mk))


hk=h/12*360+m/60*360/12
hkx=a*math.sin(math.radians(hk))
hky=a*math.cos(math.radians(hk))

l=((mkx-hkx)**2+(mky-hky)**2)**0.5
print(l)

Solution (Python):
import math

ABHM = [int(x) for x in input().split()]

chou=ABHM[3]*6
tan=ABHM[2]*30+ABHM[3]*0.5

a=abs(chou-tan)

x=math.sqrt(ABHM[0]**2+ABHM[1]**2-2*ABHM[0]*ABHM[1]*math.cos(math.radians(a)))

print(x)

"""
3 4 10 40
4.56425719433005567605
"""

Solution (Python):
import math

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

x_A = A * math.sin(math.radians((60 * H + M)/2))

y_A = A * math.cos(math.radians((60 * H + M)/2))

x_B = B * math.sin(math.radians(6 * M))

y_B = B * math.cos(math.radians(6 * M))

print(math.sqrt((x_A - x_B) ** 2 + (y_A - y_B) ** 2))

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

long = M * 6

short = (H * 60 + M ) / 2

kakudo = long - short
COS = math.cos(math.radians(kakudo))

ans = ((A**2 + B**2)-(2*A*B*COS))**0.5
print(ans)

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


import math

a = 360*H/12 + 30*M/60
b = 360*M/60


theta = min(a-b,360-a+b)


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

print(c**0.5)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
h_degree = 30*h + m/2
m_degree = 6*m
diff_degree = abs(h_degree-m_degree)

c_sq = a**2 + b**2 - 2*a*b*math.cos(math.radians(diff_degree))
print(math.sqrt(c_sq))

Solution (Python):
import math


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

hd = h * 30
md = m * 6

hd += m / 60 * 30

d = max(hd, md) - min(hd, md)

if d > 180:
    d = 360 - d

d = math.radians(d)
ans = a**2 + b**2 - 2*a*b*math.cos(d)
ans = math.sqrt(ans)
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
h+=(2*math.pi*M)/(60*12)

if h<m:
    r=m-h
    ha=A*math.sin(r)
    ba=A*math.cos(r)
    ans=(ha**2+(B-ba)**2)
    ans=math.sqrt(ans)
else:
    r=h-m
    ha=B*math.sin(r)
    ba=B*math.cos(r)
    ans=(ha**2+(A-ba)**2)
    ans=math.sqrt(ans)

print(ans)

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

Solution (Python):
import math

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

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

theta_a = (math.pi/6)*(h + m/60) % (2*math.pi)
theta_b = 2*math.pi*m/60  % (2*math.pi)
diff = abs(theta_a-theta_b)
if diff > math.pi:
    diff = 2*math.pi - diff

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

Solution (Python):
from math import cos, radians, sqrt
A, B, H, M = list(map(int, input().split()))
H = H%12
Adegree = (H*60+M)/2
Bdegree = M*6
theta = abs(Adegree - Bdegree)
print(sqrt(A*A + B*B - 2*A*B*cos(radians(theta))))

Solution (Python):
from math import cos, radians

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

ans = a ** 2 + b ** 2 - 2 * a * b * cos(radians(abs((h * 30 + m * 0.5) - (m * 6))))

print(ans ** .5)

Solution (Python):
import math

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

short_tick = {"x":0,"y":0}
long_tick = {"x":0,"y":0}

short_deg = 0
if (H >= 12) :
    H -= 12
short_deg = H * 30 + M * 0.5
long_deg = M * 6

short_tick["x"] = A * math.cos(math.radians(short_deg))
short_tick["y"] = A * math.sin(math.radians(short_deg))

long_tick["x"] = B * math.cos(math.radians(long_deg))
long_tick["y"] = B * math.sin(math.radians(long_deg))




d = pow(long_tick["x"] - short_tick["x"],2) + pow(long_tick["y"] - short_tick["y"],2)
distance = math.sqrt(d)

print(distance)

Solution (Python):
from math import cos, radians

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

hs = 360 * h / 12 + 30 * m / 60
ms = 360 * m / 60

c = (
    max(hs, ms) - min(hs, ms)
    if max(hs, ms) - min(hs, ms) <= 180
    else 360 - (max(hs, ms) - min(hs, ms))
)
c = radians(c)
ans = (a ** 2 + b ** 2 - (2 * a * b * cos(c))) ** (1 / 2)
print(ans)

Solution (Python):
import math

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

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

degsa = abs(degs - degl)
nasukaku = min(degsa, 360 - degsa)

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

print(ans)

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