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 numpy as np
A,B,H,M = list(map(int,input().split()))
tansin = H*30 + M / 2.0
tyosin = M * 6


theta  = min(abs(tansin-tyosin), 360 - abs(tansin-tyosin))

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

print(C)

Solution (Python):
import math

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

C = 2*math.pi/12
D = 2*math.pi/60
E = 2*math.pi/(12*60)
x = abs(D*M - (C*H + E*M))


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

Solution (Python):
import math

NUM = input().split()

A = float(NUM[0])
B = float(NUM[1])
H = float(NUM[2])
M = float(NUM[3])

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

X_A = A * math.cos(rad_A)
Y_A = A * math.sin(rad_A)
X_B = B * math.cos(rad_B)
Y_B = B * math.sin(rad_B)

D = math.sqrt((X_A - X_B)**2. + (Y_A - Y_B)**2.)

print(D)

Solution (Python):
import math
ll = input().split()
f1 = int(ll[0])
f2 = int(ll[1])
H = int(ll[2])
M = int(ll[3])
theta = (360*(H*60+M)/720)-(360*M/60)
a = math.sqrt(f1**2 + f2**2 - 2*f1*f2*math.cos(math.radians(theta)))
print(a)

Solution (Python):
import math

A,B,H,M = map(int,input().split())
AX = A * math.cos(2*math.pi*(H/12.+M/12./60.))
AY = A * math.sin(2*math.pi*(H/12.+M/12./60.))
BX = B * math.cos(2*math.pi*M/60.)
BY = B * math.sin(2*math.pi*M/60.)

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
pi = math.pi
xh = math.cos((0.5 - (h + m / 60) / 6) * pi) * a
yh = math.sin((0.5 - (h + m / 60) / 6) * pi) * a
xm = math.cos((0.5 - m / 30) * pi) * b
ym = math.sin((0.5 - m / 30) * pi) * b

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

Solution (Python):
import math

def ans(n):
  diff = abs(math.radians(6)*n[3] - (math.radians(30)*n[2] + math.radians(0.5)*n[3]))
  if diff < math.radians(180):
    print(math.sqrt(n[0]**2 + n[1]**2 -2*n[0]*n[1]*(math.cos(diff))))
  elif diff > math.radians(180): 
    print(math.sqrt(n[0]**2 + n[1]**2 -2*n[0]*n[1]*(math.cos(math.radians(360) - diff))))
  else:
    print(n[0] + n[1])

ans(list(map(int,input().split())))

Solution (Python):
import math

def ans(n):
  diff = abs(math.radians(6)*n[3] - (math.radians(30)*n[2] + math.radians(0.5)*n[3]))
  if diff < math.radians(180):
    print(math.sqrt(n[0]**2 + n[1]**2 -2*n[0]*n[1]*(math.cos(diff))))
  elif diff > math.radians(180): 
    print(math.sqrt(n[0]**2 + n[1]**2 -2*n[0]*n[1]*(math.cos(math.radians(360) - diff))))
  else:
    print(n[0] + n[1])

ans(list(map(int,input().split())))

Solution (Python):


import math

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

rad_h = math.radians(30) * h + (math.radians(30) / 60) * m
pos_a_x = a * math.sin(rad_h)
pos_a_y = a * math.cos(rad_h)

rad_m = math.radians(360/60) * m
pos_b_x = b * math.sin(rad_m)
pos_b_y = b * math.cos(rad_m)

x = pos_a_x - pos_b_x
y = pos_a_y - pos_b_y

l = math.sqrt(x ** 2 + y ** 2)
print(l)

Solution (Python):
A,B,H,M = list(map(int,input().split()))
import math
theta = math.pi/180*(30*H - 5.5*M)
C = math.sqrt(A*A + B*B - 2*A*B*math.cos(theta))
print(C)

Solution (Python):
import math
A,B,H,M = [int(x) for x in input().split()]
p = math.pi * 2

hx = A*math.sin((H/12 + 1/12 * M/60) * p)
hy = A*math.cos((H/12 + 1/12 * M/60) * p)
mx = B*math.sin(M/60 * p)
my = B*math.cos(M/60 * p)

ans2 = (hx - mx)**2 + (hy - my)**2
print(math.sqrt(ans2))

Solution (Python):

"""
Created on Sat May 30 18:26:16 2020

@author: Tofu
"""
import math 
def clock(A,B,H,M):
    
    
    
    
    short_hand = H*360/12+M*360/(60*12)
    long_hand = M*360/60
    
    diff1 = short_hand - long_hand
    diff2 = 360 - diff1
    if diff1 > diff2:
        diff = diff2
    else:
        diff = diff1
    
    
    rad = math.radians(diff)
    
    
    
    
    cos = math.cos(rad)
    
    
    C = math.sqrt(A*A+B*B-2*A*B*cos)
    
    
    
    return C
if __name__ == '__main__':
    A,B,H,M = input().split()
    A = float(A)
    B = float(B)
    H = float(H)
    M = float(M)
    ans = clock(A,B,H,M)
    print(ans)

Solution (Python):
import math
a,b,h,m = map(int,input().split())
ans = 0
ang = 0
tan = 30*h+0.5*m
cho = 6*m
ang = abs(cho-tan)


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

Solution (Python):
import math

short,long,hour,min=map(int,input().split())
hour = 360 / 12 * hour + 360/12/60*min
min = 360 / 60 * min

rasian = abs(hour - min)

length = math.sqrt(short*short + long*long - 2*short*long*math.cos(math.radians(rasian)))

print(length)

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

h2 = (h+(m/60)) * 30
m2 = m * 6
d = abs(h2 - m2)

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

print(c)

Solution (Python):
import math

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

a = abs(30 * H - 11/2 * M)
if a>180:
    a = 360 - a

a = math.radians(a)

b = A*A + B*B -2 * A * B * math.cos(a)
print(b**(1/2))

Solution (Python):
import math
A,B,H,M = map(float,input().split())
anH = H*30 + M * 0.5
anM = M*6
an = math.radians(abs(anH - anM))
print(math.sqrt(A * A + B * B -2 *A * B *math.cos(an)))

Solution (Python):
from math import cos, pi

value = input().split()
A = int(value[0])
B = int(value[1])
H = int(value[2])
M = int(value[3])

if 0 < A < 1001 and 0 < B < 1001 and 0 <= H <=11 and 0 <= M <= 59:
    print(pow(float(A)**2 + float(B)**2 - 2*float(A)*float(B)*cos(pi*abs(float(H)*30 - float(M)*6 + 0.5*float(M))/180),0.5))
else:
    print("Choose value in interval define on the exercise")

Solution (Python):
def rs(): return input().strip()
def ri(): return int(input())
def ria(): return list(map(int, input().split()))
def ia_to_s(a): return ' '.join([str(s) for s in a])


import math


def solve(a, b, h, m):
    h_a = 90 - 360 / 12 * (m / 60 + h)
    m_a = 90 - 360 / 60 * m
    angle = m_a - h_a

    return (a*a + b*b - 2*a*b*math.cos(angle*math.pi/180))**0.5



def main():
    a, b, h, m= ria()
    print(solve(a, b, h, m))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math

a, b, h, m = map(float, sys.stdin.readline().split(" "))

l = (h + m / 60.) / 12. * 360.
s = m / 60. * 360.
t = abs(l - s) / 360. * 2. * 3.141592653589
ans = a * a + b * b - 2.0 * a * b * math.cos(t)
print(ans ** 0.5)

Solution (Python):
from math import pi, fabs, cos, sqrt
a, b, h, m = (int(s) for s in input().split())
theta_a = 2*pi * (m/60 + h)/12
theta_b = 2*pi * m/60
theta = fabs(theta_a - theta_b)
if theta > pi/2:
    theta = 2 * pi - theta

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

Solution (Python):
line = input().rstrip().split()
import math
a = int(line[0])
b = int(line[1])

t_angle = (int(line[2]) + int(line[3])/60) /12 
m_angle = int(line[3])/60
angle = 2*(t_angle - m_angle) * math.pi


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

print(answer)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
kakudo = abs(30*H - 5.5*M)
print((A*A + B*B - 2*A*B*math.cos(math.radians(kakudo))) ** (1/2))

Solution (Python):
import math

A,B,H,M=map(int, input().split())
while H>=12:
   H=H-12
theta=abs((H+M/60)*30-M*6)

if theta>=180:
   theta =360-theta

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

Solution (Python):
import math
A, B, H, M = map(int,input().split())
Ha = H*math.pi/6 + M*math.pi/360
Ma = M*math.pi/30
if Ha == Ma:
    print(abs(A-B))
else:
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(Ha-Ma)))

Solution (Python):
import math
A,B,H,M = (int(x) for x in input().split())
c = math.cos( math.radians(30*H - 5.5*M) )
x = A**2 + B**2 - 2*A*B*c

print(math.sqrt(x))

Solution (Python):
import math 

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

ax = a[0] * math.sin(2 * math.pi * (30 * (a[2] + a[3]/60)) / 360)
ay = a[0] * math.cos(2 * math.pi * (30 * (a[2] + a[3]/60)) / 360)
bx = a[1] * math.sin(2 * math.pi * (360 * a[3] / 60) / 360)
by = a[1] * math.cos(2 * math.pi * (360 * a[3] / 60) / 360)

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

Solution (Python):
import math
A,B,H,M = list(map(int,input().split()))
Q = 30*H - 11*M/2
L = (A**2 + B**2 - 2*A*B*math.cos(math.radians(Q)))**(1/2)
print(L)

Solution (Python):
import numpy as np

A,B,H,M = map(int, input().split())
theta = (30*H + 0.5*M - 6*M) * np.pi / 180
print(np.sqrt(A**2 + B**2 - 2*A*B*np.cos(theta)))

Solution (Python):


import math

tanshin,choshin,jikan,hun=map(int,input().split(" "))

x1=tanshin*math.cos(math.radians(-(jikan*30+hun*0.5-90)))
y1=tanshin*math.sin(math.radians(-(jikan*30+hun*0.5-90)))
x2=choshin*math.cos(math.radians(-(hun*6-90)))
y2=choshin*math.sin(math.radians(-(hun*6-90)))
ans=math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
print(ans)

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

timeHr = H + (M / 60)
angVelA = (1/6) * 180
angVelB = (2) * 180

degA = (angVelA * timeHr) % (2 * 180)
degB = (angVelB * timeHr) % (2 * 180)


degDiff = abs(degB - degA) 

disX_2 = math.pow(B, 2) + math.pow(A, 2) - (2 * A * B * math.cos(math.radians(degDiff)))
disX = math.sqrt(disX_2)

print(disX)

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

timeHr = H + (M / 60)
angVelA = (1/6) * 180
angVelB = (2) * 180

degA = (angVelA * timeHr)
degB = (angVelB * timeHr) 

degDiff = math.radians(abs(degB - degA))

disX_2 = math.pow(B, 2) + math.pow(A, 2) - (2 * A * B * math.cos(degDiff))
disX = math.sqrt(disX_2)

print(disX)

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

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




md = (m/60) * 360
hd = (h/12) * 360 + (m * (360/12/60))

d = abs(md-hd)
print( (a**2 + b**2 - 2 * a * b * math.cos(math.radians(d))) **0.5)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
ang1 = (h*60 + m)/2
x = (h*60 + m) % 60
ang2 = (6 * x)

ang = abs( ang1 - ang2 )
ang = min(ang, 360 - ang) * math.pi / 180

ans = a*a + b*b - 2*a*b*math.cos(ang)
print("%.12f" % math.sqrt(ans) )

Solution (Python):
import math

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

C = math.radians(abs(30*H+0.5*M-6*M)) 

distance = float(math.sqrt(math.pow(A,2)+math.pow(B,2)-2*A*B*math.cos(C)))

print(distance)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
alpha = math.pi * M * 6 / 180
beta = (math.pi * (H * 30 + M * 0.5)) / 180
theta = abs(alpha - beta)
AB = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(theta))
print(AB)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
ang1 = (h*60 + m)/2
x = (h*60 + m) % 60
ang2 = (6 * x)

ang = abs( ang1 - ang2 )
ang = min(ang, 360 - ang) * math.pi / 180

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

Solution (Python):
import math

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

thita1 = 30*(H + M/60)
thita2 = 6*M
thita = abs(thita1 - thita2)
thita_ = max(thita, 360-thita)
c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(thita_)))
print(c)

Solution (Python):
import math
A, B, H, M = [int(i) for i in input().split()]
thetah = 30 * H + 0.5 * M
thetam = 6 * M
theta = abs(thetah - thetam)
C2 = A*A + B*B - 2*A*B*math.cos(math.pi * theta/180 )
print(math.sqrt(C2))

Solution (Python):
import math

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

deg_A = M*6
deg_B = (H*30) + (M/2)
deg_ab = abs(deg_A-deg_B)

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

Solution (Python):
import math

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

theta = (H * 30 - M * 5.5) * math.pi / 180

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

T = M + H * 60

a_x = A * math.cos(math.pi * T / 360)
a_y = A * math.sin(math.pi * T / 360)
b_x = B * math.cos(math.pi * M / 30)
b_y = B * math.sin(math.pi * M / 30)

print(math.sqrt((a_x - b_x)**2 + (a_y - b_y)**2))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b,h,m = LI()
    ar = (h / 12 + m / 12 / 60) * math.pi * 2
    ay = a * math.cos(ar)
    ax = a * math.sin(ar)
    br = m / 60 * math.pi * 2
    by = b * math.cos(br)
    bx = b * math.sin(br)

    return pow(pow(ay-by, 2) + pow(ax-bx, 2), 0.5)

print(main())

Solution (Python):
import math

A,B,H,M =map(int, input().split())
if 1<=A<=1000 and 1<=B<=1000 and 0<=H<=11 and 0<=M<=59:
    hw=(2*math.pi)/(12*60*60) 
    mw=(2*math.pi)/(60*60) 
    time_h=H*60*60 
    time_m=M*60 
    aw=hw*(time_h+time_m) 
    bw=mw*time_m 
    rad=abs(bw-aw)
    
    print(math.sqrt(A**2+B**2-2*A*B*math.cos(rad)))
    
    
else: 
    print("各値の条件は次の通り:1<=A,B<=1000,0<=H<=11,0<=M<=59")
    print("あなたの入力:A={},B={},H={},M={}".format(A,B,H,M))

Solution (Python):
import math

list_input = list(map(int, input().split()))
a = list_input[0]
b = list_input[1]
hour = list_input[2]
minute = list_input[3]


hour_angle = 2 * math.pi * (hour / 12) + math.pi / 6 * (minute / 60)  
minute_angle = math.pi / 30 * minute  
target_angle = abs(hour_angle - minute_angle)

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

target_length = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(target_angle))
print(target_length)

Solution (Python):
import math

def clock_distance(A, B, H, M):
    theta_H = 2*math.pi*(H+M/60)/12
    theta_M = 2*math.pi*M/60
    theta_D = abs(theta_H - theta_M)
    distance = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta_D))
    return distance

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

Solution (Python):
import math
A,B,H,M=map(int,input().split())
print((A*A+B*B-2*A*B*math.cos(math.radians(abs(30*H-5.5*M))))**.5)

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

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

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

Solution (Python):
import sys, os, re
from pprint import pprint
from math import sin, cos, sqrt, radians

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

a_t = radians(30*h + 0.5*m)
b_t = radians(6*m)

(a_x, a_y) = (a*cos(a_t), a*sin(a_t))
(b_x, b_y) = (b*cos(b_t), b*sin(b_t))

print(sqrt((a_x-b_x)**2+(a_y-b_y)**2))

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

long_needle = 6*m
short_needle = 30*h + m/2
deg = abs(long_needle - short_needle)


rad = math.radians(deg)
cosA = math.cos(rad)
length = math.sqrt(a**2 + b**2 - 2*a*b*cosA)

print(length)

Solution (Python):
import math

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

temp = (H%12+M/60)/12 - M/60

angle = 2*math.pi*min(abs(temp), abs(2*math.pi - abs(temp)))

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

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

x = 30*h+(m/2)
y = 6*m

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

Solution (Python):
import math

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

Solution (Python):



import math, sys
if sys.version_info[0]<3: input=raw_input

class StandardInput:

    def stdin_string(self):
        self.s=str(input().rstrip())
        return self.s

    def stdin_integer(self):
        self.n=int(input().rstrip())
        return self.n

    def stdin_array(self):
        self.arr=input().rstrip().split()
        return self.arr

    def stdin_integer_array(self):
        self.arr=list(map(int,input().rstrip().split()))
        return self.arr

def test(arr):
    a,b,h,m=arr
    ar=2*math.pi*( h/12 + m/60/12 )
    br=2*math.pi*( m/60 )
    return math.sqrt( ( a*math.cos(ar) - b*math.cos(br) )**2 + ( a*math.sin(ar) - b*math.sin(br) )**2 )

def main():
    obj=StandardInput()
    arr=obj.stdin_integer_array()
    print(test(arr))
        
if __name__ == '__main__':
    main()

Solution (Python):
import math

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

r = math.sqrt(math.pow(a,2) + math.pow(b,2) - 2*a*b* math.cos(11 * (60*h + m) * math.pi / 360) )

print(r)

Solution (Python):
import math

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

t = math.cos(11 * (60*h + m) * math.pi / 360)
r = math.sqrt(math.pow(a,2) + math.pow(b,2) - 2*a*b*t)

print(r)

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

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

H = 360*(h/12+m/(60*12))
M = 360*m/60
HM = math.radians(abs(H-M))
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(HM))

print(ans)

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

  
  
  
a=int(A)
b=int(B)
h=int(H)
m=int(M)

Pi=math.pi
radi=abs(m*Pi/30-(h*Pi/6+m*Pi/360))
ans1=math.pow(a,2)+math.pow(b,2)-2*a*b*(math.cos(radi))
ans2=math.sqrt(ans1)
print('{:.10f}'.format(ans2))

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

d=abs((h+(m/60)) * 30-6*m)
if d>180:
    d=d-180

th=math.radians((h+(m/60)) * 30)
tm=math.radians(6*m)



ans=((a*math.cos(th)-b*math.cos(tm))**2+(a*math.sin(th)-b*math.sin(tm))**2)

ans2=math.sqrt(ans)
print(ans2)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
theta = abs(H*30 - M*5.5)

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

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

deg = abs(30*h - 5.5*m)
print(math.sqrt(a*a+b*b-2*a*b*math.cos(deg*math.pi/180)))

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

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

Solution (Python):
import math


a, b, c, d = map(int, input().split())


d_th_h = 360 / (12 * 60)
d_th_m = 360 / 60

th_h = d_th_h * 60 * c + d_th_h * d
th_m = d_th_m * d

th = abs(th_h - th_m) / 180 * math.pi

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

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


hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    A, B, H, M = read_int_list()
    phi1 = 30 * H + 0.5 * M
    phi1 *= pi / 180
    x1 = A * sin(phi1)
    y1 = A * cos(phi1)

    phi2 = 6 * M
    phi2 *= pi / 180
    x2 = B * sin(phi2)
    y2 = B * cos(phi2)
    
    d2 = (x1 - x2)**2 + (y1 - y2)**2
    res = sqrt(d2)
    print(res)


main()

Solution (Python):
a,b,c,d = map(int,input().split())
import math
rad = math.fabs((c/12 - d/60 + d/720)*360)
rad = min(rad,360-rad)/180
cosine = math.cos(rad*math.pi)
print((a**2+b**2 - 2*a*b*cosine)**0.5)

Solution (Python):
import math
hourR, minR, H, M = map(int, input().split())
hourPos = [math.sin(((H * 60 + M) / 360) * math.pi) * hourR,
           math.cos(((H * 60 + M) / 360) * math.pi) * hourR]
minPos = [math.sin((M / 30) * math.pi) * minR,
          math.cos((M / 30) * math.pi) * minR]
distance = math.sqrt(
    pow(hourPos[0] - minPos[0], 2) + pow(hourPos[1] - minPos[1], 2))
print(distance)

Solution (Python):
from math import cos, radians

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

one_minute = 360 / 60
one_hour = 360 / 12
one_hour_minute = one_hour / 60

long_needle = one_minute * M
short_needle = one_hour * H + one_hour_minute * M

theta = abs(long_needle-short_needle)
if theta > 180:
    theta = 360 - theta

theta = radians(theta)

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

print(ans**0.5)

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

Solution (Python):
import math
array=input().split(" ")
A=float(array[0])
B=float(array[1])
H=float(array[2])
M=float(array[3])
D1=float(H/12*360+(M/60*30))
D2=float(M/60*360)

D=float(abs(D1-D2))
if D>180:
  D=360-D
B2=float(pow(B,2))
A2=float(pow(A,2))

ans2=B2+A2-2*B*A*(math.cos(math.radians(D)))
ans=float(pow(ans2,0.5))
print('{:.20f}'.format(ans))

Solution (Python):
import math

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

b_radius = 360/60*m
h_radius = (h*60+m) *360/(12*60)

d_radius =abs(h_radius-b_radius)
c = math.sqrt(a*a -2*a*b*math.cos(math.radians(d_radius)) +b*b)
print(c)

Solution (Python):
import math

s = list(map(float, input().split()))
htheta = 30.0*s[2]+0.5*(s[3]) 
mtheta = 6.0*(s[3]) 
theta = abs(htheta-mtheta)
if theta > 180:
    theta = 360 - theta 
r = math.sqrt(s[0]**2+s[1]**2-2*s[0]*s[1]*math.cos(math.radians(theta)))
print(r)

Solution (Python):
import math

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

rad=math.radians(abs(30*h+0.5*m-6*m))

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

Solution (Python):
from math import *

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

hr_ang = 0.5 
m_ang = 6 

t = 60*h + m

hr_ang = radians((hr_ang*t)%360)
m_ang = radians((m_ang*t)%360)

hr_cmp = (a*sin(hr_ang), a*cos(hr_ang))
mn_cmp = (b*sin(m_ang), b*cos(m_ang))
v = (hr_cmp[0]-mn_cmp[0], hr_cmp[1]-mn_cmp[1])

print(sqrt(v[0]**2 + v[1]**2))

Solution (Python):
import math
s = input()
a,b,h,m = s.split(' ')
a = int(a)
b = (int)(b)
h = int(h)
m = int(m)
t1 = h/6 * math.pi + math.pi/6*m/60
t2 = m/30 * math.pi
dellt = abs(t2 - t1)
ans = b*b + a*a - 2*a*b*math.cos(dellt)
print(ans**0.5)

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

PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647

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

angleA = 0.5*h*60 + 0.5*m;
angleB = 6*m;
angle = abs(angleA-angleB);

angle = math.radians(angle)

coss = math.cos(angle)*2*a*b;

result = math.sqrt(a*a + b*b -coss);

print(result)

Solution (Python):
import math
a,b,h,m=map(str, input().split())
h=float(h)
m=float(m)
a=float(a)
b=float(b)
mth=m*6
hth=30*h+m/2
th=math.pi*abs(mth-hth)/180
c=math.sqrt(a**2+b**2-2*a*b*math.cos(th))
print(c)

Solution (Python):
import math












line = input().split(' ')

int_line = [int(str_num) for str_num in line]







degree = abs((int_line[2] * 60 + int_line[3]) * 0.5 - int_line[3] * 6)


distance_squared = int_line[0] ** 2 + int_line[1] ** 2 - 2 * \
    int_line[0] * int_line[1] * math.cos(math.radians(degree))

distance = math.sqrt(distance_squared)

print(distance)

Solution (Python):
import math


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


rad = math.pi / 180
hour = 30 * h + m / 2
minute = 6 * m
arg = min(abs(hour - minute), 360 - abs(hour - minute))
ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad * arg))


print(ans)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
r = 30*H+M/2-6*M
if r >= 180:
    r = 360 - r
c = math.cos(math.radians(r))
l = math.sqrt(A*A+B*B-2*A*B*c)
print(l)

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

Solution (Python):
import math

params = input()

array = params.split(' ')

a = int(array[0])
b = int(array[1])
h = int(array[2])
m = int(array[3])

pi = math.pi
c = 0

totalMin = h * 60 + m
harg = 360 * totalMin / (12 * 60)
marg = 360 * m / 60


harg %= 360
marg %= 360
arg = abs(harg - marg)

arg = math.radians(arg)

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

Solution (Python):
import numpy

A, B, H, M = map(int, input().split())
theta = numpy.abs((M * 11 / 360 - H / 6 )) * numpy.pi

C_sq = A ** 2 + B ** 2 - 2 * A * B * numpy.cos(theta)
print(C_sq ** 0.5)

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

h_angle = 360 / 12 * H + 360 / 12 / 60 * M
m_angle = 360/60*M

dif_angle = (h_angle - m_angle)

c2 = A**2 + B**2-2*A*B*math.cos(dif_angle/180*math.pi)

print(math.sqrt(c2))

Solution (Python):
import math

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

h %= 12
m %= 60

theta_hour = 360 * (h/12)
theta_min = 360 * (m/60)
theta_hour += (m/2)



x1 = a * math.cos((theta_hour * math.pi) / 180)
x2 = b * math.cos((theta_min * math.pi) / 180)

y1 = a * math.sin((theta_hour * math.pi) / 180)
y2 = b * math.sin((theta_min * math.pi) / 180)


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

Solution (Python):
import math

a, b, h, m = map(float, input().split(" "))
arg_a = 2 * math.pi * (h + m / 60) / 12
arg_b = 2 * math.pi * m / 60
arg = min(abs(arg_a - arg_b), 2 * math.pi - abs(arg_a - arg_b))
"""
print(str(arg_a / (math.pi * 2) * 360)
      + " "
      + str(arg_b / (math.pi * 2) * 360))
print(str(arg_a) + " " + str(arg_b))
print(arg / (math.pi * 2) * 360)
"""
length = math.sqrt((a*a + b*b) - (2*a*b * math.cos(arg)))
print(length)

Solution (Python):
from math import cos,radians

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



dmin = 6*m
dhour = 0.5*(h*60 + m)

diff = abs(dmin - dhour)

ang = min(diff, 360- diff)

ans = pow((a**2) + (b**2) - 2*a*b*cos(radians(ang)),0.5)


print(ans)

Solution (Python):
import math

a,b,h,m = map(int, input().split())
h = (h*60+m)/2
m = m*6
cos = math.cos(math.radians(max(h,m)-min(h,m)))
u = a**2 + b**2 - 2*a*b*cos
print(u**0.5)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
min = h * 60 + m
dgr = 5.5 * min
dist = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(dgr)))
print(dist)

Solution (Python):
import math


A_B_H_M = input().split(" ")
A = int(A_B_H_M[0])
B = int(A_B_H_M[1])
H = int(A_B_H_M[2])
M = int(A_B_H_M[3])

H_angle = (2 * math.pi) * (60 * H + M) / 720
M_angle = (M / 60) * 2 * math.pi

theta = H_angle - M_angle
if theta >= 180:
  theta = theta - 180
 
ans = math.sqrt((B**2 + A**2) - (2*B*A*math.cos(theta)))
print(ans)

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


m = 6*M

h = (H * 30) + ((30/60)*M)

kakudo = min(360 - abs(m - h), abs(h - m))
kakudo_a = math.radians(kakudo)
cos_x = math.cos(kakudo_a)
 
c = A**2 + B**2 - 2*A*B*cos_x
print(math.sqrt(c))

Solution (Python):
import math

a, b, h, m = map(int, input().split())
h_theta = 2*math.pi * (60*h + m) / (60*12)
m_theta = 2*math.pi * m / 60
delta = h_theta-m_theta if h_theta>m_theta else m_theta-h_theta
l2 = a**2 + b**2 - 2*a*b*math.cos(delta)
print(math.sqrt(l2))

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

angle = 2*pai*((H+M/60)/12 - M/60)
 

distance = np.sqrt(A**2+B**2-2*A*B*np.cos(angle))
print(distance)

Solution (Python):
import math

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

ax = a*math.sin((h+m/60)/6*math.pi)
ay = a*math.cos((h+m/60)/6*math.pi)
bx = b*math.sin(m/30*math.pi)
by = b*math.cos(m/30*math.pi)

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

Solution (Python):
import math
a, b, h, m = map(float, input().split())
h_rad = h/12.0*(2.0*math.pi) + (m/60.0)*(2.0*math.pi)/12.0
m_rad = m/60.0*(2.0*math.pi)
rad = abs(h_rad-m_rad)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(rad)))

Solution (Python):
import math

A, B, H, M = (float(x) for x in input().split())

theta = H*30 + (M/60)*30 - M*6
cos = math.cos(math.radians(theta))
res = math.sqrt(A**2 + B**2 - 2*A*B*cos)
print(res)

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

Solution (Python):
import math
A,B,H,M = map(int,input().split())
r = 30*H+M/2-6*M
if r >= 180:
    r = 360 - r
c = math.cos(math.radians(r))
l = math.sqrt(A*A+B*B-2*A*B*c)
print(l)

Solution (Python):
import math





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

hp_before = [0, a]
mp_before = [0, b]

h_rect = math.radians((h / 12 + m / 60 / 12) * 360)
m_rect = math.radians(m / 60 * 360)

hp_after = [hp_before[0]*math.cos(h_rect) - hp_before[1]*math.sin(h_rect),
            hp_before[0]*math.sin(h_rect) + hp_before[1]*math.cos(h_rect)]
mp_after = [mp_before[0]*math.cos(m_rect) - mp_before[1]*math.sin(m_rect),
            mp_before[0]*math.sin(m_rect) + mp_before[1]*math.cos(m_rect)]

distance = math.sqrt( (hp_after[0]-mp_after[0])**2 + (hp_after[1]-mp_after[1])**2 )

print(distance)

Solution (Python):
import math
data = list(map(int, input().split()))

a = data[0]
b = data[1]
h = data[2]
m = data[3]

h = (h+m/60)%12
deg = (h/12-m/60)*2*math.pi
result = math.sqrt(a*a+b*b-2*a*b*math.cos(deg))
print(result)

Solution (Python):
import math

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

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

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

print(math.sqrt(C))

Solution (Python):

import math

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

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

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

if m == 0:
    kaku = h
    
elif h <= m:
    kaku = m - h
else:
    kaku = h - m

if kaku >= 180:
    360 - kaku
    
p = math.cos(math.radians(kaku))
c = A ** 2 + B ** 2 - (2 * A * B * p)
print(math.sqrt(c))

Solution (Python):
import math

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

radH = 2*math.pi*H/12 + 30/180*math.pi*M/60
radM = 2*math.pi*M/60

L = math.sqrt(A**2+B**2-2*A*B*math.cos(radH-radM))

print(L)