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

if 30 * H + (30 * M / 60) == 6 * M:
    kakudo = 0
elif 30 * H + (30 * M / 60) > 6 * M:
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H + (30 * M / 60) < 6 * M:
    kakudo = 6 * M - 30 * H - (30 * M / 60)

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

print(ans ** (1/2))

Solution (Python):
import sys
input = sys.stdin.readline
import math
def main():
    A, B, H, M = map(int, input().split())
    s_rad = 0
    if H == 0:
        s_rad = math.pi/2
    elif H <= 3:
        s_rad = (3-H)/12*2*math.pi
    else:
        s_rad = math.pi/2 + (12-H)/12*2*math.pi
    s_rad -= M/60*2*math.pi/12
    l_rad = 0
    if M == 0:
        l_rad = math.pi/2
    elif M <= 15:
        l_rad = (15-M)/60*2*math.pi
    else:
        l_rad = math.pi/2 + (60-M)/60*2*math.pi
    sx = A * math.cos(s_rad)
    sy = A * math.sin(s_rad)
    lx = B * math.cos(l_rad)
    ly = B * math.sin(l_rad)
    ans = math.sqrt(((sx-lx)**2) + ((sy-ly)**2))
    print(ans)
if __name__ == "__main__":
    main()

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

if 30 * H + (30 * M / 60) == 6 * M:
    kakudo = 0
elif 30 * H + (30 * M / 60) > 6 * M:
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H + (30 * M / 60) < 6 * M:
    kakudo = 6 * M - 30 * H - (30 * M / 60)

if kakudo > 180:
    kakudo = 360 - kakudo

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

print(ans ** (1/2))

Solution (Python):
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue



ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


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

    A, B, H, M = il()

    a = 30 * H + 30 * (M/60)
    b = 6 * M
    c = abs(a - b)
    print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(c))))


if __name__ == '__main__':
    main()

Solution (Python):
import math
A,B,H,M = list(map(int,input().split()))
hd = (30 * H + M * 0.5)
md = M * 6
d = abs(hd - md)

a = A**2 + B**2 - 2 * A * B * math.cos(math.radians(d))
print(f'{a ** 0.5}')

Solution (Python):
import math
A, B, H, M = map(int, input().split())
H *= 5
deg = abs(H+(M/12)-M)*6

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

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

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

kakudo=abs(kakudoa-kakudob)/180*math.pi

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

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

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

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

short_arrow = 360 / 12
long_arrow = 360 / 60

tmp = abs(short_arrow * H + short_arrow * (M / 60) - long_arrow * M)
kakudo = min(abs(360 - tmp), tmp)

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

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

rad = abs(h*30 + m*0.5 - m*6) * math.pi / 180
res = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(rad))

print(f"{res:.15f}")

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
l = h * 30
r = m * 6
if l > r:
    x = (l + m/2) - r
else:
    x = r - (l + m/2)
print(math.sqrt(a**2 + b**2 - 2*a*b*(math.cos(math.radians(x)))))

Solution (Python):
A,B,H,M=map(int,input().split())
import math
H_k=H*30+M/60*30
M_k=M*6
if(M_k==0):
    M_k=360
if(H_k==0):
    H_k=360

if(H_k-M_k<=180 ):
    x=H_k-M_k

else:
    x=M_k-H_k
x=abs(x)

if(x==90):

    print((A**2+B**2)**0.5)
elif(x==180):
    print(A+B)
else:

    z=((A*(math.sin(math.radians(x))))**2+(B-(A*math.cos(math.radians(x))))**2)**0.5
    
    print(z)

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

L_S =  H*30 + M/2 - 6*M

L_S = abs(L_S)
if L_S > 180 :
       L_S = 360 - L_S

print(math.sqrt(A**2+B**2 - 2*A*B*math.cos( L_S/180 * math.pi)))

Solution (Python):
from math import pi,sin,cos,tan,sqrt
a, b, h, m = map(int, input().split())
s = [cos((h/6 + m/60/6)*pi) * a, sin((h/6 + m/60/6)*pi) * a]
l = [cos((m/30)*pi) * b, sin((m/30)*pi) * b]
val = [s[0]-l[0],s[1]-l[1]]
print(sqrt(val[0]**2 + val[1]**2))

Solution (Python):
import sys
import math
from collections import Counter
import itertools
import fractions
from decimal import Decimal



def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

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

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



A,B,H,M=MI()

kakuM = M*6
kakuH = H*30+0.5*M
 
kakudo = kakuH - kakuM

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

Solution (Python):

import math
a,b,h,m = map(float,input().split())
s = abs((0.5*m + 30*h) - 6*m)
if s > 180:
  s = 360 - s

y = s * (math.pi / 180)
x = math.sqrt(a*a+b*b-2*a*b*math.cos(y))
print(x)

Solution (Python):
from math import *

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

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

if theta > 180:
    theta = 360 - theta

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

Solution (Python):
import math

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

rad_A = (2 * math.pi / 12) * (H + M / 60)
rad_B = (2 * math.pi / 60) * M

rad = abs(rad_A - rad_B)
rad = min(rad, 2*math.pi - rad)

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

print(c)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import sqrt, cos, pi

a, b, h, m = map(int, read().split())
theat = abs(h * 30 - 6 * m + m / 2) * pi / 180
print(sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theat)))

Solution (Python):
import math
from decimal import Decimal as D
from decimal import *

getcontext().prec = 1000

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


def d_round(d):
    return d.quantize(D('0.1') ** D(100), ROUND_DOWN)

def get_point(a, deg):
    r = math.radians(deg)
    return (a * d_round(D(math.cos(r))), a * d_round(D(math.sin(r))))


h_deg = D(360) - (D(H) % D(12)) / D(12) * D(360) + D(90)
m_deg = D(360) - (M % D(60)) / D(60) * D(360) + D(90)

h_deg -= (M % D(60) / D(60)) * D(30)

a_p = get_point(D(A), h_deg)
b_p = get_point(D(B), m_deg)

print(((a_p[0] - b_p[0]) ** D(2) + (a_p[1] - b_p[1]) ** D(2)) ** (D(1) / D(2)))

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

alp=2*math.pi*(h/12+m/(12*60)-m/60)
ans=math.sqrt(a**2+b**2-2*a*b*(math.cos(alp)))

print(ans)

Solution (Python):
import sys
import math
from collections import Counter
import itertools
import fractions
from decimal import Decimal



def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())

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

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



A,B,H,M=MI()



kakuM = M*6
kakuH = (H+M/60)*30 - kakuM


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

print(Decimal(ans).sqrt())

Solution (Python):
import sys
import math


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    a, b, h, m = _ia()
    ad = 30*h + .5*m
    bd = 6 * m
    dd = math.radians(ad-bd)
    return (a**2+b**2-2*a*b*math.cos(dd))**.5


if __name__ == "__main__":
    print(main())

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

theta = abs(30 * H + 0.5 * M - 6 * M)
if theta > 180:
    theta = 360 - theta

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

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

import math
P_a = H * 30 + M * 0.5
P_b = M *6

kakudo = P_a - P_b
if kakudo < 0:
    kakudo *= -1
elif kakudo == 0:
    print(abs(A - B))
    exit()
elif kakudo == 180:
    print(A + B)
    exit()

if kakudo > 180:
    kakudo = 360 - kakudo

kyori_sq = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(kakudo))
print(math.sqrt(kyori_sq))

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

if 30 * H == 6 * M + (30 * M / 60):
    kakudo = 0
elif 30 * H > 6 * M + (30 * M / 60):
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H < 6 * M + (30 * M / 60):
    kakudo = 6 * M - 30 * H - (30 * M / 60)


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

print(ans ** (1/2))

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

if 30 * H == 6 * M + (30 * M / 60):
    kakudo = 0
elif 30 * H > 6 * M + (30 * M / 60):
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H < 6 * M + (30 * M / 60):
    kakudo = 6 * M - 30 * H - (30 * M / 60)

if kakudo > 180:
    kakudo = 360 - kakudo

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

print(ans ** (1/2))

Solution (Python):
import math

A, B, H, M = [int(a) for a in input().split()]
h_d = -2*math.pi/12
m_d = -2*math.pi/60

h_s = h_d*(H+M/60) + math.pi/2
m_s = m_d*M + math.pi/2

h_y = A*math.sin(h_s)
h_x = A*math.cos(h_s)
m_y = B*math.sin(m_s)
m_x = B*math.cos(m_s)

x = h_x - m_x
y = h_y - m_y

ans = math.sqrt(pow(x,2)+pow(y,2))
print("{:.20f}".format(ans))

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

Solution (Python):
import math

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

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


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

print(ans)

Solution (Python):
import math

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

ax = A * math.cos((180-(H*60+M))/720*2*math.pi)
ay = A * math.sin((180-(H*60+M))/720*2*math.pi)
bx = B * math.cos(((15-M)/60)*2*math.pi)
by = B * math.sin(((15-M)/60)*2*math.pi)


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

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

degA = (H%12 / 12 + (M%60/60)/12) * math.pi*2
degB = (M%60 / 60) * math.pi*2

ax = math.sin(degA)*A
ay = math.cos(degA)*A
bx = math.sin(degB)*B
by = math.cos(degB)*B

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

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

ang_m = M * 6
ang_h = H * 30 + M * 0.5
ang = max(ang_h, ang_m) - min(ang_h, ang_m)

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

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


H = 360 * (h / 12) + 30 * (m / 60)
M = 360 * (m / 60)
sa = abs(H-M)

if sa < 180:
    x = sa
else:
    x = 360 - sa

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

Solution (Python):
from math import radians, cos

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

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

Solution (Python):
import math

class abc_168:
    
    def __init__(self):
        pass
    
    def A(self):
       N=int(input())
       hon=[2,4,5,7,9]
       pon=[0,1,6,8]
       bon=[3]
       
       ans=N%100
       ans=ans%10
       
       if ans in hon:print("hon")
       elif ans in pon:print("pon")
       else :print("bon")
    
    def B(self):
        K=int(input())
        S=input()
        
        if len(S)<=K:print(S)
        else:
            ans=S[0:K]+"..."
            print(ans)
        
    def C(self):
        ABHM=list(map(int,input().split()))
        
        radi=abs((ABHM[2]*5)+((ABHM[3]*5)/60)-ABHM[3])*6
        
        ans=(ABHM[0]**2)+(ABHM[1]**2)-(2*ABHM[0]*ABHM[1]*math.cos(math.radians(radi)))
        print(math.sqrt(ans))
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_168()
    obj.C()

Solution (Python):
import math

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

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

a=A*math.cos(theta)-B*math.cos(phi)
b=A*math.sin(theta)-B*math.sin(phi)

dist=math.sqrt(a**2+b**2)

print(dist)

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

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

a, b, h, m = [int(x) for x in input().split()]

percentage = m / 60
hourAngle = (h + percentage) * 30
minuteAngle = (m/5) * 30
ans = sqrt(a**2 + b**2 - (2*a*b*cos(radians(abs(hourAngle - minuteAngle)))))
print(ans)

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

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

if __name__ == '__main__':
    resolve()

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

h_angle = (360/12 * H) + (M * 0.5)
m_angle = 360/60 * M

tri_angle = abs(h_angle - m_angle)

C = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(tri_angle)))
print(C)

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


key = 360 / 720 * m
a_i = 360 / 12 * h + key  
b_i = 360 / 60 * m  
kaku = abs(a_i - b_i)










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

print(math.sqrt(ans))

Solution (Python):
import math

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


ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(+(M / 60 * 2 * math.pi) - ((H / 12+M/60/12) * 2 * math.pi))
print(ans ** 0.5)

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

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    A, B, H, M = map(int, rl().split())
    
    rad_h = 0.5 * (60 * H + M)
    rad_m = M * 6
    rad = min(abs(rad_h - rad_m), abs(rad_m - rad_h))
    ans = ((A ** 2) + (B ** 2) - (2 * A * B * cos(radians(rad)))) ** 0.5
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import math
def yogen(x,y,z):
  return (x*x+y*y-2*x*y*math.cos(math.radians(z)))**0.5

a,b,h,m=map(int,input().split())
k=30*(h+m/60)-6*m
print(yogen(a,b,k))

Solution (Python):
import math
def main():
    A, B, H, M = map(int, input().split())
    x = abs(30 * H - 6 * M + 0.5 * M)
    x = math.radians(x)
    if x == 1:
        return A + B
    x = min(x, 2*math.pi - x)
    C = A**2 + B**2 - 2 * A * B * math.cos(x)
    return math.sqrt(C)
print(main())

Solution (Python):
import numpy as np
A, B, H, M = list(map(int, input().split()))
print(np.sqrt(A**2+B**2-2*A*B*np.cos(np.deg2rad(abs(360*((H+M/60)/12-M/60))))))

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

Solution (Python):
import math

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

angle = abs((H + M / 60) / 12 - M / 60) * 2 * math.pi
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle))
print(ans)

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

Solution (Python):
import math
a,b,h,m=map(int,input().split())
H=(12-h-m/60)/12
M=(60-m)/60






ax=a*math.sin(2*math.pi*H)-b*math.sin(2*math.pi*M)
ay=a*math.cos(2*math.pi*H)-b*math.cos(2*math.pi*M)

bx=b*math.sin(2*math.pi*M)
by=b*math.cos(2*math.pi*M)





c=(ax**2+ay**2)**0.5

print(c)

Solution (Python):
import math

x = list(map(int,input().split(" ")))
a,b,h,m = x
angle = abs(6*m - 30*(h + m/60))
angle_cos = math.cos(math.radians(angle))
ans = (a**2 + b**2 - 2*a*b*angle_cos) ** 0.5
print(ans)

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

md = m / 60 * 360

bx = math.sin(math.radians(md)) * b
by = math.cos(math.radians(md)) * b

hd = h / 12 * 360 + m / 60 * 30

ax = math.sin(math.radians(hd)) * a
ay = math.cos(math.radians(hd)) * a

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

Solution (Python):
import math
A,B,H,M = map(int, input().split())
rate = M / 60
HM = H*5 + 5*rate
theta = abs(HM-M) * 6
if theta > 180:
    theta = 360-theta
rad = math.radians(theta)
cos = (math.cos(rad))
L = math.sqrt(A*A + B*B - 2*A*B*cos)
print("{:.19f}".format(L))

Solution (Python):
from math import radians,cos
a,b,h,m=map(int,input().split())
degree=h*30+m*0.5-m*6
degree=min(360-degree,degree)

X=cos(radians(degree))
print((a**2+b**2-2*a*b*X)**0.5)

Solution (Python):


from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

len_hour_hand, len_minute_hand, hour, minute = map(int, input().split())

d_short = hour / 12 + (minute / 60) / 12
d_long = minute / 60


degrees = 360 * abs(d_long - d_short)
degrees = min(degrees, 360 - degrees)
radians = math.radians(degrees)

res = len_minute_hand ** 2 + len_hour_hand ** 2 - 2 * len_minute_hand * len_hour_hand * math.cos(radians)
print(math.sqrt(res))

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

Solution (Python):
import math
a,b,h,m=map(float,input().split())
pi=math.pi
th=((h+(m/60))*(2*pi))/12
tm=((2*pi)*m)/60
diff=abs(th-tm)
val=a*a+b*b-2*a*b*math.cos(diff)
print(math.sqrt(val))

Solution (Python):
import math

num_list=list(map(int,input().split()))

laptured_time = num_list[2] *60 + num_list[3]
 

degrees = abs(num_list[3]*6-laptured_time/2)

degrees=math.radians(degrees)
length= math.sqrt(num_list[0]**2+num_list[1]**2-2*num_list[0]*num_list[1]*math.cos(degrees))
print(length)

Solution (Python):
import math


if __name__ == "__main__":
    a, b, h, m = input().split()

    a = int(a)
    b = int(b)
    h = int(h)
    m = int(m)

    theta = 2.0 * math.pi * (h + m / 60.0) / 12.0
    phi = 2.0 * math.pi * m / 60.0

    xa = a * math.sin(theta)
    ya = a * math.cos(theta)

    xb = b * math.sin(phi)
    yb = b * math.cos(phi)

    distance = math.sqrt(math.pow(xa-xb, 2) + math.pow(ya-yb, 2))

    print(distance)

Solution (Python):

from math import pi, cos

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    A, B, H, M = MII()
    
    theta = abs(H*30-6*M+M/2)*pi/180
    print((A**2+B**2-2*A*B*cos(theta))**(1/2))


if __name__ == '__main__':
    main()

Solution (Python):
a,b,h,m = map(int,input().split())
ans = 0
 
import math
 
rada = (2*math.pi/12)*(h+m/60)
radb = (2*math.pi/60)*m
 
if rada >= radb:
  theta = rada - radb
else:
  theta = radb - rada
  
if theta < math.pi:
  pass
else:
  theta = 2*math.pi - theta
 
ans = math.sqrt(a**2+b**2 - 2*a*b*math.cos(theta))
 
print(ans)

Solution (Python):






"""Module docstring
"""

import functools
import heapq
import itertools
import logging
import math
import os
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict, deque
from copy import deepcopy
from io import BytesIO, IOBase
from typing import Dict, List, Optional, Set, Tuple


def solve(a: int, b: int, h: int, m: int) -> float:
    hour_angle = 2 * math.pi * (h / 12 + m / 60 / 12)
    LOG.debug((hour_angle))
    hour_x = a * math.cos(hour_angle)
    hour_y = a * math.sin(hour_angle)
    LOG.debug((hour_x, hour_y))
    min_angle = 2 * math.pi * m / 60
    min_x = b * math.cos(min_angle)
    min_y = b * math.sin(min_angle)
    LOG.debug((min_x, min_y))
    return math.sqrt((hour_x - min_x) ** 2 + (hour_y - min_y) ** 2)


def do_job(stdin, stdout):
    "Do the work"
    LOG.debug("Start working")
    
    A, B, H, M = map(int, stdin.readline().split())
    result = solve(A, B, H, M)
    print("{:.20f}".format(result), file=stdout)


def print_output(testcase: int, result, stdout) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case 
    
    


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


def configure_log() -> None:
    "Configure the log output"
    log_formatter = logging.Formatter("L%(lineno)d - " "%(message)s")
    handler = logging.StreamHandler(IOWrapper(sys.stderr))
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None

if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    stdin = IOWrapper(sys.stdin)
    stdout = IOWrapper(sys.stdout)
    do_job(stdin, stdout)
    stdout.flush()
    for h in LOG.handlers:
        h.flush()
    return 0


if __name__ == "__main__":
    sys.exit(main())

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

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

rot_a = h*30 + m*0.5
rot_b = m*6
rot = rot_a-rot_b if rot_a>rot_b else rot_b-rot_a
if rot > 180:
  rot = min(rot_a, rot_b) + 360 - max(rot_a, rot_b)

ans = sqrt(a**2 + b**2 - 2*a*b*cos(rot*pi/180))
print(ans)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
deg_c = math.pi * (60 * h - 11 * m) / 360

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

print(c)

Solution (Python):


import math


def get_input() -> tuple:
    """
    標準入力の取得.

    Returns:\n
        tuple: 標準入力
    """
    A, B, H, M = list(map(int, input().split()))

    return A, B, H, M


def main(A: int, B: int, H: int, M: int) -> None:
    """
    求解処理.

    Args:
        A (int): 時針の長さ（1 <= A <= 1000）
        B (int): 分針の長さ（1 <= B <= 1000）
        H (int): 何時（0 <= H <= 11）
        M (int): 何分（0 <= M <= 59）
    """
    """
    余弦定理により、距離を求める.
    """
    PI = math.pi
    angle_A = PI * H / 6 + PI * M / 360
    angle_B = PI * M / 30
    angle = max(angle_A, angle_B) - min(angle_A, angle_B)
    result = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))

    
    print(result)


if __name__ == "__main__":
    A, B, H, M = get_input()
    main(A, B, H, M)

Solution (Python):
import math

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

KA = H / 12 * 360 + ((M / 60) * (360 / 12))
KB = M / 60 * 360

K = abs(KA - KB)
if K > 180:
    K = 360 - K







cosB = math.cos(math.radians(K))
cc = A ** 2 + B ** 2 - (2 * B * A * cosB)
print(math.sqrt(cc))

Solution (Python):
import math
a,b,h,m=map(int,input().split())
h=h+m/60
h=h/12*360
m=m/60*360
d=abs(h-m)
if d>180:
	d=360-d
print((a**2+b**2-2*a*b*math.cos(math.radians(d)))**(1/2))

Solution (Python):
import numpy as np

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

ar = np.radians((360 - (30 * h + m / 2)) + 90)
br = np.radians((360 - (6 * m)) + 90)

xa = a * np.cos(ar)
ya = a * np.sin(ar)

xb = b * np.cos(br)
yb = b * np.sin(br)

al = np.array([xa, ya])
bl = np.array([xb, yb])
u = bl - al
print(np.linalg.norm(u))

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

Solution (Python):
import math

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

KA = H / 12 * 360 + ((M / 60) * (360 / 12))
KB = M / 60 * 360

K = abs(KA - KB)
if K > 180:
    K = 360 - K






cosB = round(math.cos(math.radians(K)), 13)
cc = A ** 2 + B ** 2 - (2 * B * A * cosB)
print(math.sqrt(cc))

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

ta = 30*H + 0.5*M
tb = 6*M

t = math.fabs( ta - tb )

if t > 180.0:
    t = 360.0 - t



t = (t*pi)/180.0

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

print("{:.9f}".format(math.sqrt(ans)))

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

a_angle = 30*h + m/2
b_angle = 6*m
angle=a_angle-b_angle

As = a**2
Bs = b**2
D = 2*a*b

result = sqrt(As + Bs - D*cos(radians(angle)))
print(result)

Solution (Python):
import math
lis = list(map(int, input().split(' ')))
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 = math.radians(calcAngle(lis[2], lis[3]))
print(math.sqrt(lis[0]*lis[0]+lis[1]*lis[1]-2*lis[0]*lis[1]*math.cos(a)))

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



c1 = h*30 + m*0.5

c2 = m*6
Cd = 0

if c1 > c2:
    Cd = c1-c2
else:
    Cd = c2-c1


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

Solution (Python):
import math
a=input().split()
A=int(a[0])
B=int(a[1])
H=int(a[2])
M=int(a[3])
M_deg=M*6
H_deg=H*30+M*0.5

HM_deg=abs(H_deg-M_deg)

Y=math.cos(math.radians(HM_deg))
x=math.sqrt(A*A+B*B-2*A*B*Y)
print(x)

Solution (Python):
import math

A,B,H,M = map(int, input().split())
AR = 360*H/12+30*M/60
BR = 360*M/60

if abs(AR-BR)<180:
  X = abs(AR-BR)
else:

  X = 360-abs(AR-BR)



C = A**2+B**2-2*A*B*math.cos(math.radians(X))
print(C**0.5)

Solution (Python):
import os
import math

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

    rand2 = 6 * m
    rand3 = (0.5 * m) + (30 * h)
    rand_result = 0.0

    if (abs(rand3 - rand2) <= 180):
        rand_result = abs(rand3 - rand2)
    else:
        rand_result = 360 - abs(rand3 - rand2)

    
    ans = math.sqrt(pow(a,2) + pow(b,2) - (2*a*b*math.cos(math.radians(rand_result))))
    print(format(ans,'.10f'))

if __name__ == "__main__":
    main()

Solution (Python):
import math

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

deg_val_hr = h*(math.pi/6)

deg_val_min = 11*m*(math.pi/360)

deg_diff = abs(deg_val_hr - deg_val_min);


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

print(math.sqrt(ans))

Solution (Python):
import math
import numpy as np

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

x = ((h * 60 + m) * 360 /(720))
y = (m * 6)
num = abs(x - y)

print(math.sqrt(a * a + b * b - 2 * a * b * np.cos(np.radians(min(num, 360 - num)))))

Solution (Python):
a, b, h, m = map(int, input().split())
h_angle = h * 30 + m /2
m_angle = m * 6
angle = h_angle - m_angle
import math
angle_cos = math.cos(math.radians(angle))
c_2 = a ** 2 + b ** 2 - 2 * a * b * angle_cos
c = math.sqrt(c_2)
print(c)