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):
a, b, h, m = map(int, input().split())

import math


rad_diff = min(abs(m/60-(h+m/60)/12), abs((h+m/60)/12-m/60))*2*math.pi
yogen = math.sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(rad_diff))
print(yogen)

Solution (Python):
import math

def main():
    A,B,H,M = (int(x) for x in input().split())
    h = H + M/60
    hangle = 2 * math.pi * h / 12
    mangle = 2 * math.pi * M / 60
    ans = A**2 + B**2 - 2*A*B*math.cos(abs(hangle-mangle))
    print(math.sqrt(ans))

if __name__ == '__main__':
    main()

Solution (Python):

import sys
import math


def solve(A: int, B: int, H: int, M: int):
    angle = abs(H / 12 + (M / 60)/ 12 - M / 60) * 2 * math.pi
    print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle)))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    H = int(next(tokens))  
    M = int(next(tokens))  
    solve(A, B, H, M)


if __name__ == "__main__":
    main()

Solution (Python):
import math

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

h_angle = 360*H/12 + 360*M/(12*60)
m_angle = 360*M/60
angle = abs(m_angle - h_angle)
if angle > 180:
    angle = 360 - angle
elif angle < 180:
    pass
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(angle)))
print(C)

Solution (Python):
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

from math import cos,radians

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

long_ = (30*h) + (0.5*m)
short_ = 6*m
difference = min([abs(long_-short_),abs(long_-short_-360)])
temp = a**2+b**2 - (2*a*b*cos(radians(difference)))
print(temp**0.5)

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

sho_deg = h*0 + m*6 
lon_deg = h*30 + m*0.5 

deg_dif = abs(sho_deg-lon_deg)

print((a**2 + b**2-2*a*b*math.cos(deg_dif/180*math.pi))**0.5)

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

sho_deg = h*0 + m*6 
lon_deg = h*30 + m*0.5 

deg_dif = abs(sho_deg-lon_deg)

print((a**2 + b**2-2*a*b*math.cos(deg_dif/180*math.pi))**0.5)

Solution (Python):
import sys, os

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

f = lambda:list(map(int,input().split()))

def get_qsa(file_name):
    audio, size = readfile(file_name)
    headers = {
        'Connection': 'keep-alive',
        'Content-Length': str(size)
    }

    
    parameter = {
                "request_id":int(time.time()*100),
                "th":1,
                "tht":"qf492_100fps",
                "the":1.000000,
                "thst":"neural"
                }
    res = requests.post(f"http://{config['ip']}:{config['port']}", timeout=120, data=audio, headers=headers, params = parameter)
    

    res_json = res.json()
    


    if res_json['retmsg']!="success":
        raise Exception
    

    bin_str = res_json["th"][0]["feat"]
    bin_data = base64.b64decode(bin_str)

    bin2qsa_siren(bin_data, file_name)


def solve():
    from math import sqrt, pi, cos
    a,b,h,m = f()

    theta1 = (h + m/60) / 12
    
    theta2 = m/60

    l = sqrt(a**2 + b**2 - 2 * a * b * cos( 2*pi * abs(theta1 - theta2)))
    print(f"{l:.10f}")

       
    
solve()

Solution (Python):
import math

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

cho = (H * 60 + M) / (12 * 60) * 360
tan = M / 60 * 360
degree = abs(cho-tan)

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

Solution (Python):
import math
inf = input().split()  
theta = (int(inf[2])-int(inf[3])*11/60)*math.pi/6
print((float(inf[0])**2 + float(inf[1])**2 - 2*float(inf[0])*float(inf[1])*math.cos(theta))**(1/2))

Solution (Python):
import math

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

theta1 = 2 * math.pi / 12 * H + 2 * math.pi / 60 / 12 * M  
theta2 = 2 * math.pi / 60 * M

x = math.sqrt(A*A + B*B - 2.0 * A * B* math.cos(theta1 - theta2))

print(x)

Solution (Python):
import math

s=input().split()
for i in range(len(s)):
    s[i]=int(s[i])
a,b,h,m=s[0],s[1],s[2],s[3]
if(h>12):h-=12

radh=h/12*360+m/2;
radm=m*6;
radh=radh/180*math.pi
radm=radm/180*math.pi

theta=abs(radh-radm)
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().strip().split())
minH=6*M
HrH=0.5*(H*60+M)
Ang=abs(HrH-minH)

Ans=math.sqrt(A**2+B**2-2*A*B*math.cos((math.pi/180)*Ang))
Ans=str(Ans)
if "." in Ans:
    intg=Ans.split(".")[0]
    decimal=Ans.split(".")[1]
    if len(decimal)<9:
      print(intg+"."+decimal+"0"*(9-len(decimal)))
    else:
      print(intg+"."+decimal[:9])
else:
   print(Ans+"."+"0"*9)

Solution (Python):
import math

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

angle = math.radians(abs((h * 30 + 0.5 * m)  - m * 6))
print(math.sqrt((a ** 2 + b ** 2) - 2 * a * b * math.cos(angle)))

Solution (Python):

def main():
    import sys
    imput = sys.stdin.readline
    
    
    
    A, B, H, M = map(int, input().split())

    
    
    
    
    
    
    
    
    
    

    import math
    delta = (H + M/60)*math.pi/6 - (M/30)*math.pi
    C = pow(A, 2) + pow(B, 2) - 2*A*B*math.cos(delta)
    print(math.sqrt(C))  

    
if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin
import math


def main():
    A, B, H, M = [int(x) for x in stdin.readline().rstrip().split()]

    ang_hour = (60 * H + M) * math.pi / 360
    ang_minute = (M / 30) * math.pi
    ang_btw = math.fabs(ang_hour - ang_minute)
    ang = min(ang_btw, 2 * math.pi - ang_btw)

    c = A ** 2 + B ** 2 - (2 * A * B * math.cos(ang))
    print(c ** 0.5)


if __name__ == "__main__":
    main()

Solution (Python):
import math

n=tuple(map(int,input().split()))

A=n[0]
B=n[1]
H=n[2]
M=n[3]

A_rad=H*math.pi/6+M*math.pi/360
B_rad=M*math.pi/30


A_pos=[A*math.cos(A_rad),A*math.sin(A_rad)]
B_pos=[B*math.cos(B_rad),B*math.sin(B_rad)]

print(math.sqrt((A_pos[0]-B_pos[0])**2+(A_pos[1]-B_pos[1])**2))

Solution (Python):
from math import pi, cos, sin, sqrt
def main():
    a, b, h, m = map(int, input().split())
    m_rad = 2*pi * m / 60
    h_rad = 2*pi * (h/12 + 1/12*m/60)
    h_x, h_y = a*cos(h_rad), a*sin(h_rad)
    m_x, m_y = b*cos(m_rad), b*sin(m_rad)
    print(sqrt(abs(h_x - m_x)**2 + abs(h_y - m_y)**2))

if __name__ == "__main__":
    main()

Solution (Python):
import math
import numpy as np
inp = list(map(int, input().split()))

A = inp[0]
B = inp[1]
H = inp[2]
M = inp[3]

H = H*60 + M
A_theta = H*0.5
B_theta = M*6
theta = abs(A_theta - B_theta)
if theta > 180.0:
    theta = 360-theta

ans = (A**2) + (B**2) - (2*A*B*math.cos(theta*(2*np.pi/360)))
print(np.sqrt(ans))

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

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

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

p = 6*m
j = 30*h + m/60*30

if p >= j:
    if p - j < 180:
        w = p-j
    else:
        w = 360 - p + j
else:
    if j-p <180:
        w = j-p
    else:
        w = 360 - j + p



c = math.cos(math.radians(w))

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

print(C)

Solution (Python):
import math
import numpy as np

i=list(map(int,input().split()))
a=i[0]
b=i[1]
h=i[2]
m=i[3]

m_arg=math.radians((360/60)*m)
h_arg=math.radians((360/12)*h+(360/12/60)*m)
h_v=a*np.array([math.cos(h_arg),math.sin(h_arg)])
m_v=b*np.array([math.cos(m_arg),math.sin(m_arg)])

print(np.linalg.norm(h_v-m_v))

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

kakua = H * 30 + M * 0.5
kakub = M * 6

kaku = max(kakub - kakua, kakua - kakub)

if kaku > 180:
    kaku = 360 - kaku

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

Solution (Python):
import math

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

sitaX = 30 * H +  M / 2
sitaY = 6 * M

cosC = math.cos(math.radians(abs(sitaX - sitaY)))

C_2 = A*A + B*B - 2*A*B*cosC

print (math.sqrt(C_2))

Solution (Python):
import math
i = list(map(int, input().split()))
a = i[0]

b = i[1]

h = i[2]

m = i[3]


ma = m*6


ha = h*30+0.5*m


ang = ha -ma


e = math.cos(math.radians(ang))
d = a*a + b*b -2*a*b* e

c = math.sqrt(d)
print(c)

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

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

import math

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

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

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

Solution (Python):
import math

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

ha = 30 * H + 0.5 * M
if M == 0 :
    ma = 360
else:
    ma = 6 * M

if ha > ma:
    an = ha - ma
    print((A**2 + B**2 - (2 * A * B * round(math.cos(math.radians(an)),20)))**0.5)
elif ma > ha:
    an = ma - ha
    print((A**2 + B**2 - (2 * A * B * round(math.cos(math.radians(an)),20)))**0.5)
else:
    if H == 6 and M == 0:
        print(A+B)
    else:
        print(B-A)

Solution (Python):
from math import cos,radians,sqrt
a,b,h,m=map(int,input().split())
hangle= 30*h + 0.5*m
mangle= 6*m
angle=abs(hangle-mangle)
angle=min(360-angle,angle)
ans= (a**2 + b**2 - (2*a*b*cos(radians(angle))))
print(sqrt(ans))

Solution (Python):
import math

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

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

C = A*A + B*B - 2*A*B*math.cos(math.radians(s))

print(math.sqrt(C))

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

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

Solution (Python):
from math import cos, radians
A, B, H, M = map(int, input().split())  
hour_hand = H*30 + M*0.5
minit_hand = M*6
c = (A**2 + B**2 - 2*A*B*cos(radians(hour_hand-minit_hand)))**(1/2)
print(c)

Solution (Python):
def c_colon_dist():
    from cmath import pi, exp
    A, B, H, M = [int(i) for i in input().split()]
    def rot(h, rad): return h * exp(1j * (pi / 2 - rad))

    hour_rad, minute_rad = (60 * H + M) * pi / 360, M * pi / 30
    hour_pos, minute_pos = rot(A, hour_rad), rot(B, minute_rad)
    return abs(hour_pos - minute_pos)

print(c_colon_dist())

Solution (Python):
from math import *
a, b, h, m = map(int, input().split())
h = (30*h + 0.5*m) * pi/180 
m = 6*m * pi/180
theta = min(abs(h-m), 360-abs(h-m))
ans = sqrt(a**2 + b**2 - 2*a*b*cos(theta))
print(ans)

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

angle = min((30*H + 0.5*M) - 6*M, 360-((30*H + 0.5*M) - 6*M))
angle1 = math.floor(angle * 10 **2) / (10 **2)
ang_rad = math.radians(angle1)

cos = math.cos(ang_rad)
x = math.sqrt(A**2 + B**2 - 2*A*B*cos)

print(x)

Solution (Python):
import math

a, b, h, m = [int(x) for x in input().split()]
radH = (360 / 12 * h + 30 / 60 * m) / 180 * math.pi
radM = (360 / 60 * m) / 180 * math.pi
ax, ay = math.cos(radH) * a, math.sin(radH) * a
bx, by = math.cos(radM) * b, math.sin(radM) * b
ans = ((ax - bx) ** 2 + (ay - by) ** 2) ** 0.5
print(ans)

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

jisin = H*30+M*(1/2)
hunsin = M*6
kakudo = max(jisin - hunsin,hunsin-jisin)
if kakudo >= 180:
    kakudo = 360-kakudo
    

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

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

mc = 360*m/60
hc = 360*(h/12+m/720)
c = abs(mc-hc)
c = min(c, 360-c)

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

Solution (Python):
import math
a,b,h,m = map(int,input().split())
H = h*30+m*0.5
M = m*6
cosA = math.cos(math.radians(H-M))
c = math.sqrt(a**2+b**2-2*a*b*cosA)
print(c)

Solution (Python):
import math

nums = list(map(int, input().split()))
a = nums[0]
b = nums[1]
h = nums[2]
m = nums[3]

a_rad = 30 * h + 0.5 * m
b_rad = 6 * m
rad = abs(a_rad - b_rad)

if rad > 180:
    rad = 360 - rad
    
cos = math.cos(math.radians(rad))

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

print(c)

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

theta_m = 6*m
theta_h = 30*h+m/2
theta = abs(theta_h-theta_m)
r = math.radians(theta)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(r))
print(ans)

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

r_m = 6*m
r_h = 30*h + 0.5*m
r = math.radians(abs(r_h - r_m))
x2 = a*a + b*b - 2*a*b*math.cos(r)
print(math.sqrt(x2))

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

A, B, H, M = [int(el) for el in input().split()]

minutes = H * 60 + M
h = 360.0 / 60.0 * (minutes % 60)
m = 360.0 / 720.0 * (minutes % 720)
ang = abs(h - m)

print(sqrt(A*A + B*B - 2.0 * A * B * cos(radians(ang))))

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

Solution (Python):
import math
A, B, H, M = map(int, input().split())
h = 30 * H + M / 2
m = 6 * M
alpha = abs(h-m)

if alpha > 180:
    alpha = 360 - alpha

theta = 2 * math.pi * alpha / 360
ans = (A**2 + B ** 2 - 2 * A * B * math.cos(theta))**0.5

print("{:.15f}".format(ans))

Solution (Python):
a,b,h,m = [int(i) for i in input().split()]
 
from math import cos,radians,degrees
angle = 3.14159265358979323846264338327950 * 2.0 * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0)
print((a**2 + b**2 - 2 * a * b * cos(angle))**0.5)

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

theta = abs((30*h + 0.5*m) - 6*m)
theta = min(theta,360-theta)

import math
c = (a**2 + b**2 -2*a*b*math.cos(math.radians(theta)))**0.5

print(c)

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

Solution (Python):
import math

a = list(map(int,input().split()))
A = a[0]
B = a[1]
H = a[2]
M = a[3]
theta = abs(30*H-5.5*M)
ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(theta))
print(math.sqrt(ans))

Solution (Python):
import math

A,B,H,M=map(int,input().split())
z=H+M/60
n=math.radians(30*z)
m=math.radians(6*M)

X1=A*(math.sin(n))
X2=A*(math.cos(n))
Y1=B*(math.sin(m))
Y2=B*(math.cos(m))

S=((X1-Y1)**2+(X2-Y2)**2)**0.5
print(S)

Solution (Python):
import math

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

minitu = 360*(m/60)

hour = 360*(h/12)+(360//12)*(m/60)

kakudo = min(abs(hour-minitu),360-abs(hour-minitu))

kakudo_ra = math.radians(kakudo)

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

print(c)

Solution (Python):
import math

A, B, H, M = list(map(int, input().split()))
l = (2*math.pi)/(12*60*60)
s = (2*math.pi)/(60*60)

t = H * 60 * 60 + M * 60
tt = M * 60

lr = l * t
sr = s * tt

x1 = A * math.cos(lr)
y1 = A * math.sin(lr)

x2 = B * math.cos(sr)
y2 = B * math.sin(sr)

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

Solution (Python):

import sys
from math import sin, cos, radians

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


A, B, H, M = lr()
d1 = radians(30 * H + 30 * M / 60)
d2 = radians(360 * M / 60)

C = A * A + B * B - 2 * A * B * cos(d1-d2)
answer = C ** .5
print(answer)

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

Solution (Python):
import math
HL,ML,h,m=(int(x) for x in input().split())
HW=float((60*h+m)/2)
MW=float(6*m)

if HW > MW:
    if HW-MW>180:
        w=360-(HW-MW)
    else:
        w=HW-MW
    print(math.sqrt(HL*HL+ML*ML-2*HL*ML*math.cos(math.radians(w))))
else:
    if HW-MW>180:
        w=360-(HW-MW)
    else:
        w=HW-MW
    print(math.sqrt(HL*HL+ML*ML-2*HL*ML*math.cos(math.radians(-w))))

Solution (Python):
import math

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

minutes = (m*360)/60
hours = ((h+m/60)*360)/12

def getPos(theta, length):
    y=length*math.sin(math.radians(theta))
    x=length*math.cos(math.radians(theta))
    return [x,y]

x1,y1 = getPos(hours, a)
x2,y2 = getPos(minutes, b)

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

Solution (Python):
from cmath import rect, tau

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

t = 60 * H + M
a = rect(A, t * tau / (12 * 60))
b = rect(B, t * tau / 60)

print(abs(a - b))

Solution (Python):
from math import sqrt, cos, radians
A, B, H, M = map(int, input().split())
theta = 30*H + M*0.5 - 6*M
theta = radians(theta)

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

Solution (Python):
import math

A, B, H, M = map(int, input().split())
m_angle = M * 6
h_angle = H * 30 + M * 0.5
angle = abs(m_angle - h_angle)
angle = min(angle, 360 - angle)

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

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

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

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

d = abs(360//12*(h+m/60)-360//60*m)
ans = a**2+b**2
ans -= 2*a*b*math.cos(math.radians(d))
ans = ans**0.5
print(ans)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
A = (m * 6)
B = (h * 30) + (m * 0.5)

C = min(abs(A - B), 360 - abs(A - B))
D = math.cos(math.radians(C))

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

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

t = h * 60 + m
th_a = ((0.5 * t) / 360.0) * 2 * cmath.pi
th_b = ((6.0 * t) / 360.0) * 2 * cmath.pi

za = cmath.rect(a, th_a)
zb = cmath.rect(b, th_b)

c = abs(za - zb)
print(c)

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

start = 30*H
start -= 5.5*M
if start >=180:
  start = 360-start

syahen = A**2 + B**2 - 2*A*B*math.cos(math.radians(start))
print(math.sqrt(syahen))

Solution (Python):
import math as mt
a, b, h, m = map(int, input().split())
hd = h*30
md = m*6
hd += md/12
d = abs(hd - md)
cd = mt.cos(d* mt.pi/180)
print(round(mt.sqrt(a*a + b*b - 2*a*b*cd), 20))

Solution (Python):
A,B,H,M = map(float, input().split())
 
import math
 
degreeA = float((H * 60 + M) / 2)
degreeB = float(M * 6)
 
degreeAB = abs(degreeA - degreeB)
if degreeAB == 180:
    print(A + B)
elif degreeAB > 180:
    degreeAB = 360 - degreeAB
    C = float(A ** 2 + B ** 2 - 2 * A * B * float(math.cos(float(degreeAB * math.pi / 180))))
    print(math.sqrt(C))
else:
    C = float(A ** 2 + B ** 2 - 2 * A * B * float(math.cos(float(degreeAB * math.pi / 180))))
    print(math.sqrt(C))

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

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

l = (a**2 + b**2 -2*a*b*math.cos(math.radians(abs(k_a-k_b))))**.5

print(l)

Solution (Python):
import math

def radi(deg):
    return deg * (math.pi / 180)

def resolve():
    ha, hb, h, m = map(int, input().split())
    hr = radi(30*h+(m/2))
    mr = radi(6*m)
    hx = ha * math.cos(hr)
    mx = hb * math.cos(mr)
    hy = ha * math.sin(hr)
    my = hb * math.sin(mr)
    v = (abs(hx - mx)**2 + abs(hy - my)**2)**0.5
    print(v)
resolve()

Solution (Python):
import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = 360 - kakudo

kakudo = abs((math.radians(kakudo)))
ans =( chou**2 + tan**2 - 2*chou*tan*math.cos(kakudo))**.5
print(ans)

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

Solution (Python):
import math
a,b,h,m=map(int,input().split())
theta_h=30*h+1/2*m
theta_m=6*m
theta=abs(theta_h-theta_m)
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(theta)))
print(c)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
rad_a = 30 * H + 0.5 * M
rad_b = 6 * M

K = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(rad_a - rad_b))
print(K ** 0.5)

Solution (Python):
import math
a, b, h, m = [int(_) for _ in input().split()]
print(math.sqrt(b ** 2 - 2 * a * b * math.cos(math.radians(abs(30*h+m/2 - 6*m))) + a ** 2))

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


minutes=h*60+m

sx=b*math.cos(math.radians((90-6*minutes)%360))
sy=b*math.sin(math.radians((90-6*minutes)%360))

tx=a*math.cos(math.radians((90-0.5*minutes)%360))
ty=a*math.sin(math.radians((90-0.5*minutes)%360))


l = math.sqrt(
    (sx-tx)**2 + (sy-ty)**2
    )

print(l)

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

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

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

import math
x = ((30*h)+30*(m/60))%360
y = (6*m)%360
s = abs(x-y) if abs(x-y) < 180 else 360 - abs(x-y)


k = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(s)))

print(k)

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

Solution (Python):
import sys
input = sys.stdin.readline
import math
def main():
    A, B, H, M = map(int, input().split())
    radh = (H*60+M)/720 * 2*math.pi
    radm = M/60 * 2*math.pi
    hx, hy = A*math.cos(radh), A*math.sin(radh)
    mx, my = B*math.cos(radm), B*math.sin(radm)
    ans = math.sqrt((hx-mx)**2 + (hy-my)**2)
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
import math

a, b, h, m = map(float, input().split())
hour = 30 * h + 0.5 * m
minute = 6 * m

radian = abs(hour - minute)
if radian > 180:
    radian = 360 - abs(hour - minute)

dist = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radian))
print(math.sqrt(dist))

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, h, m = nm()

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

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


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

C = math.radians(5.5*m-30*h)
print((a**2+b**2-2*a*b*math.cos(C))**0.5)

Solution (Python):
import math

a,b,h,m = map(int,input().split())
tan_sin = math.pi * (h + m/60) / 6  
cho_sin = math.pi * m/30   

theta = tan_sin - cho_sin
c = math.cos(theta)

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

print(ans)

Solution (Python):
import math

a, b, h, m = map(float, input().split())
hour = 30 * h + 0.5 * m
minute = 6 * m

radian = abs(hour - minute)

if radian < 180:
    dist = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radian))
    print(math.sqrt(dist))
elif radian == 180:
    print(a + b)
else:
    radian = 360 - radian
    dist = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(radian))
    print(math.sqrt(dist))

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

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b, h, m = MAP()

hm = h*60 + m

heach = hm / 720
meach = m / 60
hdig = heach * 360
mdig = meach * 360

hx = a * cos(radians(hdig))
hy = a * sin(radians(hdig))
mx = b * cos(radians(mdig))
my = b * sin(radians(mdig))

ans = hypot(hx-mx, hy-my)
print(ans)

Solution (Python):
"""
・なんとか自力AC。大変だった。これ本当に300点か。。
・三角形、角度、三角関数、余弦定理
・2辺の長さが分かっていてもう1辺を知りたいので、角度が分かればいいなーって気持ちになる。
・時刻が与えられるが、短針の微妙な位置とか分からんだろ、ってなる。
・ここで先にD解いたり、Eしばらく考えたりして、E厳し目っぽかったので戻ってきた。
・もう1回、300点でそんな高度な要求がある訳ないという前提の元、考え直してみる。
・ここでやっと、1分毎に動く量を出せば経過時間から割り出せると分かる。
・ちょっとゴニョゴニョして無事角度が出て、さて、2辺と角度が揃ったらどうするんだっけな、とググる。
・余弦定理の公式が出てきて、あぁこんなんあったな、と当てはめる。無事AC。
・こういうのを300点っていう低難度で出せちゃうのは、やっぱり競プロは数学ゲーなんだな、と改めて思わされる所。
"""

import sys
from math import sin, cos, radians, hypot

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b, h, m = MAP()

hm = h*60 + m

heach = hm / 720
meach = m / 60
hdig = heach * 360
mdig = meach * 360

hx = a * cos(radians(hdig))
hy = a * sin(radians(hdig))
mx = b * cos(radians(mdig))
my = b * sin(radians(mdig))

ans = hypot(hx-mx, hy-my)
print(ans)

Solution (Python):
import math

a,b,h,m = map(int,input().split())
tan_sin = math.pi * (h + m/60) / 6
ji_sin = math.pi * m/30
theta = tan_sin - ji_sin
c = math.cos(theta)

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

print(ans)

Solution (Python):
import math

def main():
    A, B, H, M = map(int, input().split())
    m_x = B * math.cos(2*math.pi*M/60)
    m_y = B * math.sin(2*math.pi*M/60)
    h = H / 12 + M/60/12
    h_x = A * math.cos(2*math.pi*h)
    h_y = A * math.sin(2*math.pi*h)
    
    ans = math.sqrt((m_x - h_x)**2 + (m_y - h_y)**2)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math

A, B, H, M = map(int, sys.stdin.readline().split())
theta = (H * 30 + M * 0.5)  - (M * 6)
ans = math.sqrt((A**2 + B**2) - (2 * A * B) * math.cos(math.radians(theta)))
print('{:.20f}'.format(ans))

Solution (Python):
import math
def c168(a, b, h, m):

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

    kaku = abs(hh - mm) if 180 >= abs(hh - mm) else 360 - abs(hh - mm)

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

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

    return ans

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

if __name__ == '__main__':
    main()

Solution (Python):

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

    from math import sin, cos, pi, sqrt

    ar = pi/2 - 2*pi/12*h - 2*pi/60/12*m
    br = pi/2 - 2*pi/60*m

    ax, ay = a * cos(ar), a * sin(ar)
    bx, by = b * cos(br), b * sin(br)

    c = sqrt((ax-bx)**2+(ay-by)**2)

    print(c)


if __name__ == "__main__":
    main()

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

def MAP(num,u,t,nu,nt):
    return (num-u)*(nt-nu)/(t-u)+nu

shitah=MAP(H*60+M,0,12*60,np.radians(90),np.radians(-270))
posh=[A*np.cos(shitah),A*np.sin(shitah)]
shitam=MAP(M,0,60,np.radians(90),np.radians(-270))
posm=[B*np.cos(shitam),B*np.sin(shitam)]
ans=((posh[0]-posm[0])**2+(posh[1]-posm[1])**2)**0.5
print(ans)

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

s2 = minutes/720

sita = s1-s2

sita *= math.pi*2

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

Solution (Python):
import math
import decimal
xh = 0
yh = 0
xm = 0
ym = 0

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

th = (h*60+m)/720*2*math.pi
tm = (m)/60*2*math.pi

xh = (a)*math.cos(th)
yh = (a)*math.sin(th)
xm = b*math.cos(tm)
th = b*math.sin(tm)

x = abs(xh-xm)
y = abs(yh-th)
ans = math.sqrt(x**2+y**2)
print(format(ans, '.9f'))

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

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


degree_a = -360 * (H * 60 + M) / (60 * 12)
radian_a = radians(degree_a)
degree_b = -360 * (M / 60)
radian_b = radians(degree_b)

A = {
    'x': A * cos(radian_a),
    'y': A * sin(radian_a),
}
B = {
    'x': B * cos(radian_b),
    'y': B * sin(radian_b),
}

distance = sqrt((A['x'] - B['x']) ** 2 + (A['y'] - B['y']) ** 2)

print(distance)

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

L =30*h +0.5*m
M =6*m
angle =max(L,M)-min(L,M)
if angle >180:
    angle =360-angle
A=cos(angle*pi/180)


ans =sqrt(a*a+b*b -2*a*b*A)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
import math
def main():
    A, B, H, M = map(int, input().split())
    hour = math.radians(360/12)
    minute = math.radians(360/60)
    hm = math.radians(1/2)
    Ax = math.cos((hour*H + hm*M ))*A
    Ay = math.sin((hour*H + hm*M))*A
    Bx = math.cos((minute*M))*B
    By = math.sin((minute*M))*B
    
    
    
    ans = math.sqrt(abs(Ax-Bx)*abs(Ax-Bx) + abs(Ay-By)*abs(Ay-By))
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import math
a,b,h,m = map(int,input().split())
pi = math.pi
dh = 30 * h
dh += 0.5 * m
dm = 6 * m
diff = abs(dh - dm)
if diff > 180:
    diff = 360 - diff
x = b * b + a * a - 2 * a * b * math.cos(diff * pi / 180)
ans = math.sqrt(x)
print(ans)

Solution (Python):
import math

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

rad_A = math.radians(H * 30 + M / 2)
rad_B = math.radians(M * 6)

A_x = A * math.cos(rad_A)
A_y = A * math.sin(rad_A)
B_x = B * math.cos(rad_B)
B_y = B * math.sin(rad_B)

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

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