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
 
date0=input().rstrip().split(" ")
A=int(date0[0])
B=int(date0[1])
H=int(date0[2])
M=int(date0[3])
P=(H+(M/60))*30
Q=M*6
if P>Q:
    R=P-Q
else:
    R=Q-P
if R>=180:
    R=360-R
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(R))))

Solution (Python):
import math

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

h_hand = (m+(h*60))*0.5
m_hand = m*6

degree = abs(h_hand - m_hand)

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

sq = a**2 + b**2 -2*a*b*cos_x

print(math.sqrt(sq))

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

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

Solution (Python):
import math

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

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

tmp = math.radians(h - m)

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

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

rad = h/12.0 + m/(60*12) - m/60.0
rad = 2*p * rad

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

print(ans**(0.5))

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

print((a**2+b**2-2*a*b*math.cos(math.radians(y)))**0.5)

Solution (Python):
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


import numpy as np

A, B, H, M = read_ints()

thetaA = (H + M / 60) / 12 * 2 * np.pi
thetaB = (M / 60) * 2 * np.pi
pA = A * np.exp(complex(0, thetaA))
pB = B * np.exp(complex(0, thetaB))

print(np.abs(pA - pB))

Solution (Python):
import math
 
a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * (360/(60*12))
deg_b = m * (360/60)
deg = abs(deg_a - deg_b)
rad = math.radians(deg)
 
c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
ang=6*m-30*h-m/2
if ang<0:
    ang*=-1
ang=ang*math.pi/180


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

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
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 [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

class AnalogClock():
  def __init__(self,h,m):
    self.h=h
    self.m=m
    self.SHDegree=30*h+m/2
    self.LHDegree=6*m

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

  aclock=AnalogClock(h,m)

  x=aclock.SHDegree
  y=aclock.LHDegree
  sita=abs(x-y)
  if sita>180:
    sita=360-sita

  z=a*a+b*b-(2*a*b*math.cos(sita*math.pi/180))
  return math.sqrt(z)


print(main())

Solution (Python):
import math
a,b,h,m=map(int,input().split())
h=(h+m/60)*30
m=m*6
if m==0:m=360
j=max(m,h)-min(m,h)
if j>180:j=360-j
if j==180:print(a+b)
elif j==0:print(max(a,b)-min(a,b))
elif j==90:print(math.sqrt(a**2+b**2))
else:print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi/(180/j))))

Solution (Python):
import math
 
[a, b, h, m] = [int(x) for x in input().split(" ")]
short = ((h) * 60 + m) / (12 * 60) * 360
long = (m) / (60) * 360
theta = abs(long - short)
inte = math.cos(math.radians(theta))
print(math.sqrt(a ** 2 + b ** 2- 2*a * b * inte))

Solution (Python):
import math as m
[A, B, H, M] = list(map(int, input().split()))
H_d = H * 30 + 0.5 * M 
M_d = M * 6

C = abs(H_d - M_d)
if C >= 180:
  C = 360 - C
cosC = m.cos(m.radians(C))

answer = (A ** 2 + B ** 2 - 2 * A * B * cosC) ** 0.5
print(answer)

Solution (Python):
PI = 3.14159265358979323846264338327950

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

mw = (PI)/(30)

hw = (PI)/(6)

ang = 2*PI*(h/12 + (m/60)/12 - m/60)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(ang))

print(c)

Solution (Python):
import math

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

angH = H*30 + M*0.5
angM = M*6
ang = abs(angH - angM)

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

print(ans)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
alpha = (60*H+M) * math.pi /360
beta = M * math.pi / 30
theta = min(abs(alpha-beta), 2*math.pi-(alpha-beta))

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

print(ans)

Solution (Python):
import math

a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * 0.5
deg_b = 6 * m
deg = deg_a - deg_b
rad = math.radians(deg)

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

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

import numpy as np
pi=np.pi

def clock(A,B,H,M):
    angleA=(H+M/60)/12*2*pi
    angleB=M/60*2*pi
    delta=angleA-angleB
    X_squared=A**2+B**2-2*A*B*np.cos(delta)
    X=np.sqrt( X_squared)
    print(X)
    
clock(A,B,H,M)

Solution (Python):
import math

def solve():
    shorts_cm, longs_cm, hour, minute = map(int, input().split())

    shorts_degree = (hour * 60 + minute) * 0.5
    longs_degree = minute * 6.0

    degree = abs(longs_degree - shorts_degree)
    degree = min(degree, 360-degree)
    aPower2 = abs(shorts_cm ** 2 + longs_cm ** 2 + (-2 * shorts_cm * longs_cm * math.cos(math.radians(degree))))

    print(math.sqrt(aPower2))

solve()

Solution (Python):
import math

a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * 0.5
deg_b = 6 * m
deg = abs(deg_a - deg_b)
rad = math.radians(deg)

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

Solution (Python):


import sys
import math

input = iter(sys.stdin.readlines()).next

def dist(x1, y1, x2, y2):
   return math.sqrt((x1-x2)**2 + (y1-y2)**2)

def main():
   A, B, H, M = map(int, input().split())
   a = (H + M/60.0) * 2 * math.pi / 12
   yA = math.sin(a) * A
   xA = math.cos(a) * A

   b = M * 2 * math.pi / 60
   yB = math.sin(b) * B
   xB = math.cos(b) * B




   res = dist(xA, yA, xB, yB)
   print('%.12f' % (res))

   return 0


if __name__ == '__main__':
   sys.setrecursionlimit(10000)
   main()

Solution (Python):

import math

A,B,H,M = map(int,input().split(' '))
rad = abs((H*30+M/2)-M*6)
rad = math.radians(min(rad,360-rad))
print('{:.20f}'.format((A**2 + B**2 - 2*A*B*math.cos(rad))**0.5))

Solution (Python):
import math

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

S = 360/720*(H*60+M)
L = 360/60*M
tmp = abs(L-S)

print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.pi*(min(tmp,360-tmp))/180)))

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

Solution (Python):
import math

inp = str(input())
inp = inp.split()

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

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

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

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

print(c)

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

Solution (Python):
import sys
import numpy as np
import math

a,b,h,m = map(int,input().split())
time = h+m/60.0


angle = np.abs(30*time-m*6)%360
angle = min(angle, 360-angle)
print('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))

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

def main():
    a, b, h, m = map(int, input().split())
    h_deg = math.pi * 2 * ((h / 12) + ((m / 60) / 12))
    m_deg = math.pi * 2 * (m / 60)

    deg = h_deg - m_deg
    print(math.sqrt(a**2 + b**2 - (2 * a * b * math.cos(deg))))

if __name__ == '__main__':
    main()

Solution (Python):
import math

def abs(x):
  return x if x >= 0 else -x

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

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

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

Solution (Python):


import math


I = input().split()
A = int(I[0])

B = int(I[1])

H = int(I[2])

M = int(I[3])



tha = 30*H + .5*M
thb = 6*M
diff= (math.pi/180)*(tha-thb)
Q = math.cos(diff)

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



print(d)

Solution (Python):



                        
                        
                        
                        



import sys
import math


def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MODPRIME = int(1e9+7); BABYMOD = 998244353;

def getangle(hour, minu):
    h = (hour * 360) / 12 + (minu * 360) / (12 * 60)
    m = (minu * 360) / (60);
    angle = abs(h-m)
    return min(angle, 360-angle)


a, b, h, m = get_ints()
angle = getangle(h, m)
coss = math.cos((angle/180)*math.pi)
ans = ((a**2)+(b**2)-(2*a*b*coss))
print(math.sqrt(ans))



'''
THE LOGIC AND APPROACH IS BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
: DO NOT PLAGIARISE.
'''

Solution (Python):
import math

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


c = 11.0/360.0*(60*h+m)*math.pi
x = math.sqrt(a * a + b * b - 2 * a * b * math.cos(c))
print(x)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
angle1 = 360 / 60 * m
angle2 = (60 * h + m) * 360 / (60 * 12)
angle3 = angle2 - angle1
c = math.radians(angle3)
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(c))
print(ans)

Solution (Python):
import math




















MOD = 10**9 + 7
A,B,H,M = map(int,input().split())

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

xH = A*math.cos(math.radians(kakuH))
yH = A*math.sin(math.radians(kakuH))
xM = B*math.cos(math.radians(kakuM))
yM = B*math.sin(math.radians(kakuM))

ans = (xH-xM)**2 + (yH-yM)**2
ans = math.sqrt(ans)
print(ans)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
H = 30 * h + 0.5 * m
M = 6 * m
angle = abs(H - M)

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

Solution (Python):
import math

A, B, H, M = map(int, input().split())
angleH = 360 * ((H + (M / 60)) / 12)
angleM = 360 * (M / 60)
angle = abs(angleH - angleM)
answer = math.sqrt(math.pow(A, 2) + math.pow(B, 2) - (2 * A * B * math.cos(math.radians(angle))))
print(answer)

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

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


th = m/60 * 2*pi
tm = (60*h + m)/720 * 2*pi
xh = a*cos(th)
yh = a*sin(th)
xm = b*cos(tm)
ym = b*sin(tm)
dx = xh-xm
dy = yh-ym
ans = sqrt(dx*dx + dy*dy)
print(ans)

Solution (Python):
import math

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

Mw = M*6
Hw = H*30 + (0.5)*M
Q = math.cos(math.radians(abs(Mw-Hw)))

C = A**2 + B**2 - 2*A*B*Q
C = math.sqrt(C)
print(float(C))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
H = (30 * h)%360 + 0.5 * m
M = 6 * m
angle = abs(H - M)

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

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

import math

ax = math.sin(2*math.pi * (H * 60 + M) / (12 * 60)) * A
ay = math.cos(2*math.pi * (H * 60 + M) / (12 * 60)) * A

bx = math.sin(2*math.pi * M / 60) * B
by = math.cos(2*math.pi * M / 60) * B

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

print(result)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
if m != 0:
    h += m / 60

ax = math.cos(math.radians(h * 30)) * a
ay = math.sin(math.radians(h * 30)) * a
bx = math.cos(math.radians(m * 6)) * b
by = math.sin(math.radians(m * 6)) * b

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

Solution (Python):
import math

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

angle_h = 2 * math.pi * H / 12 + 2 * math.pi * M / (12 * 60)
angle_m = 2 * math.pi * M / 60

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

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

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

Solution (Python):



def dos(H,M):
    H%=12
    return min(abs(30*H-5.5*M),360-abs(30*H-5.5*M))


import math 
def radi(H,M):
    H%=12
    return math.pi*min(abs(30*H-5.5*M),360-abs(30*H-5.5*M))/180

from math import cos,sqrt
a,b,h,m=map(int,input().split())
print(sqrt(a**2+b**2-2*a*b*cos(radi(h,m))))

Solution (Python):
import math

A, B, H, M = map(int, input().split())
long_rad = math.radians(M * 6)
short_rad = math.radians(H * 30 + M / 60 * 30)
A_x, A_y = math.cos(short_rad) * A, math.sin(short_rad) * A
B_x, B_y = math.cos(long_rad) * B, math.sin(long_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())

hh = (h * 60 + m) * 0.5
mm = m * 6
do = max(hh, mm) - min(hh, mm)
do = min(do, 360 - do)
sin = math.sin(math.radians(do))
if do == 90:
    print(math.sqrt(a ** 2 + b ** 2))

elif do > 90:
    hi = b * sin
    a_sub = math.sqrt(b ** 2 - hi ** 2)
    hy = math.sqrt((a + a_sub) ** 2 + hi ** 2)
    print(hy)

elif do < 90:
    hi = b * sin
    a_sub = math.sqrt(b ** 2 - hi ** 2)
    hy = math.sqrt((a_sub - a) ** 2 + hi ** 2)
    print(hy)

Solution (Python):

import math

def calculate_length(A,B,theta):
    radian=math.radians(theta)
    length=(A**2)+(B**2)-(2*A*B*math.cos(radian))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    thetaA=H*30+M*0.5
    thetaB=M*6
    if thetaA == thetaB:
        print(abs(A-B))
    else:
        if thetaA > thetaB:
            theta=thetaA-thetaB
        elif thetaA < thetaB:
            theta = thetaB-thetaA
        length=calculate_length(A,B,theta)
        print(length)

if __name__=="__main__":
    main()

Solution (Python):
import math
A,B,H,M=map(int,input().split())
 
hun=6*M
ji=30*H+(1/2)*M
 
if math.radians(hun-ji)==0:
    a=abs(A-B)
elif hun-ji==180 or ji-hun==180:
    a=A+B
else:
    a = (A ** 2 + B ** 2 - 2* A * B * math.cos(math.radians(hun-ji))) ** (1 / 2)
print(a)

Solution (Python):
import math

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

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

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

if __name__ == "__main__":
    main()

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

A_ang = 30*H+30*M/60
B_ang = M*360/60


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

Solution (Python):
import math 
a,b,c,d=map(int,input().split())
s=c/12+d/720-d/60
s=abs(s)*2*math.pi
e=(a**2+b**2-2*a*b*math.cos(s))
print(e**0.5)

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

A_ang = 30*H+30*M/60
B_ang = M*360/60


ang = A_ang - B_ang
out = float(A**2+B**2)-float(2*A*B*math.cos(math.radians(ang)))
print(math.sqrt(out))

Solution (Python):
import math

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

h = H/12 + M/60/12
m = M/60


r = abs(h - m)*math.pi*2

C = (A**2 + B**2 - 2*A*B*math.cos(r))**(1/2)
print(C)

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

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

Solution (Python):
import math
a,b,h,m=map(int,input().split())
ad=((h*60+m)/2)%(12*60)
bd=m*6
p=min(abs(bd-ad),360-abs(bd-ad))
q=a**2+b**2-2*a*b*math.cos(p/180*math.pi)
print(abs(q**0.5))

Solution (Python):
import math
 
 
a,b,h,m=map(int, input().split())
 
 
d = 30*(h+m/60)-6*m
e = 360-d
f = min(d,e)
y = math.cos(math.radians(f))
 
 
x = a**2+b**2-2*a*b*y
z = float(math.sqrt(x))
print("{0:.20f}".format(z))

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

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

big = max(30*h + (m*0.5), 6*m)
small = min(30*h + (m*0.5), 6*m)
gap = min(big - small, 360 - (big - small))

print(format(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))), ".20f"))

Solution (Python):

import math
a, b, h, m = [float(i) for i in input().split()]
omega_b  = 2*math.pi/(60**2) 
omega_a  = omega_b/12 

theta_a = omega_a * (h*60**2 + m*60)
theta_b = omega_b * m*60


c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(abs(theta_a-theta_b)))
print(c)

Solution (Python):
import math

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

minute = H * 60 + M
theta = 360 / 12 / 60 * minute
phi = 360 / 60 * M

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

print(C)

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

arg_h = (H+M/60)/12 *2*math.pi
arg_m = M/60 * 2 * math.pi

print(math.sqrt(pow(A, 2) +pow(B, 2) -2*A*B*math.cos(arg_h-arg_m)))

Solution (Python):
from cmath import rect, pi

def deg_to_rad(deg): return deg * pi / 180

a, b, h, m = map(float, input().split())
zh = rect(a, deg_to_rad((60*h+m) / 2))
zm = rect(b, deg_to_rad(m * 6))
print(abs(zh-zm))

Solution (Python):
import math
a,b,h,m = map(int, input().split())
time = 60*h + m
Adeg = 0.5*time
Bdeg = 6*time
Arad = math.radians(0.5*time) 
Brad = math.radians(6*time)
x1 = a*math.sin(Arad)
y1 = a*math.cos(Arad)
x2 = b*math.sin(Brad)
y2 = b*math.cos(Brad)
ans = ((x1-x2)**2 + (y1-y2)**2)**0.5
print(ans)

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

Solution (Python):
import math

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

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

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

Solution (Python):


import math

def calculate_length(A,B,rad):
    length=(A**2)+(B**2)-(2*A*B*math.cos(math.pi*rad/180))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    rad = abs((H*60+M)*0.5-M*6)
    length=calculate_length(A,B,rad)
    print(length)

if __name__=="__main__":
    main()

Solution (Python):
import math
a,b,h,m = map(int,input().split())
long = m/60*360
short = h*30+(m/60*30)
kakudo = abs(long-short)
if kakudo > 180:
    kakudo = 360-kakudo
ans = math.sqrt(a**2 + b**2 - (2*a*b*math.cos(math.radians(kakudo))))
print(ans)

Solution (Python):
import math

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

hmove = 360 / 12 * h + 360 / 12 / 60 * m
mmove = 360 / 60 * m


rad = math.radians(abs(hmove - mmove))


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

Solution (Python):
def c_colon_dist():
    from math import pi, sin, cos, dist
    A, B, H, M = [int(i) for i in input().split()]

    hour_hand_rad = (60 * H + M) * pi / 360
    minute_hand_rad = M * pi / 30
    hour_hand_pos = (sin(hour_hand_rad) * A, cos(hour_hand_rad) * A)
    minute_hand_pos = (sin(minute_hand_rad) * B, cos(minute_hand_rad) * B)
    return dist(hour_hand_pos, minute_hand_pos)

print(c_colon_dist())

Solution (Python):







import math
import sys

def degtorad(deg):
    return deg / 180.0 * math.pi

def main():
    a, b, h, m = map(int, input().split())
    alpha = m / 60 * 360
    beta = h / 12 * 360 + m / 60 * 30
    deg = abs(alpha - beta)
    c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(degtorad(deg)))
    print("{:0.9f}".format(c))


if __name__ == "__main__":
    main()

Solution (Python):
import os

import cmath
import math
import sys

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

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


A, B, H, M = list(map(int, sys.stdin.buffer.readline().split()))

h = A * cmath.rect(1, (H / 12 + M / 60 / 12) * math.pi * 2)
m = B * cmath.rect(1, (M / 60) * math.pi * 2)
print(abs(h - m))

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

import math

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

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

    if x == 0 or x== 360:
        print(abs(a-b))
    elif x == 180:
        print(a+b)
    else:
        if x > 180:
            x = 360 - x

        rad = math.radians(x)

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

        print(math.sqrt(ans_2))

if __name__ == '__main__':
    main()

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








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

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

Solution (Python):
import math
from sys import stdin


def get_result(data):
    A, B, H, M = data
    h_deg = (H + M/60.0) * 30.0
    m_deg = M * 6.0
    theta = math.radians(abs(m_deg - h_deg))
    ans = math.sqrt(A**2+B**2 - 2*A*B*math.cos(theta))
    return ans


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)

Solution (Python):
import math
import decimal
a,b,h,m = map(int,input().split())
long = m/60*360
short = h*30+(m/60*30)
kakudo = abs(long-short)
if kakudo > 180:
    kakudo = 360-kakudo
dum = kakudo/180*3.141592653589793238462643
radi = math.cos(dum)
ans = a**2 + b**2 - (2*a*b*radi)
ans = ans ** (1/2)
print(ans)

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

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

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

thetah = (h+(m/60))/12*2*pi
thetam = m/60*2*pi

theta = thetah - thetam
mx, my = a, 0
hx, hy = b*cos(theta), b*sin(theta)
ans = sqrt((mx-hx)**2+(my-hy)**2)
print(ans)

Solution (Python):
import math
a,b,h,m = map(int, input().split())
h2 = h*30 + m*6/360*30
m2 = m*6
if h2 <= m2 :
    c = m2 - h2
    ans = a**2 + b**2 -2*a*b*math.cos(math.radians(c))
    print(math.sqrt(ans))
else:
    c = h2 - m2
    ans = a**2 + b**2 -2*a*b*math.cos(math.radians(c))
    print(math.sqrt(ans))

Solution (Python):
import math
from math import sqrt
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
from copy import deepcopy

INF=10**18
MOD=10**9+7
MAX=10**5+7




if __name__=='__main__':
  a,b,h,m=map(int, input().split())

  s=h*30+30*m/60
  t=360*m/60

  th=min(abs(s-t), 360-abs(s-t))
  c=sqrt(a**2+b**2-2*a*b*math.cos(math.radians(th)))
  print(c)

Solution (Python):
import math

def main():
    A,B,H,M = [int(x) for x in input().split()]
    degH = (0.5*H*60 + 0.5*M)
    degM = 6*M
    theta = abs(degH-degM)
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta))))

if __name__ == '__main__':
    main()

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

import math

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

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

    if x == 0 or x== 360:
        print(abs(a-b))
    elif x == 180:
        print(a+b)
    else:


        rad = math.radians(x)

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

        print(math.sqrt(ans_2))

if __name__ == '__main__':
    main()

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

Solution (Python):
a,b,H,M = map(int, input().split())

import math

c = a*a + b*b -2*a*b*math.cos(2 * math.pi*((H*60+M)/720 - M/60))

ans = math.sqrt(c)

print(ans)

Solution (Python):

import sys
import math
def calcAngle(h,m): 
        if (h < 0 or m < 0 or h > 12 or m > 60): 
            return 0
        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) 
        pi=22/7
        radian = angle*(math.pi/180)
        return radian 
def solve(A: int, B: int, H: int, M: int):
    C = calcAngle(H,M)
    ans = (A**2 + B**2 - 2*A*B*math.cos(C))**0.5
    print(ans)
    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())

pi = math.pi
ht = h*pi/6+m*pi/360
mt = m*pi/30

if ht >= mt:
    theta = ht -mt
else:
    theta = mt - ht

ll = a**2 + b**2 -2*a*b*math.cos(theta)

print(math.sqrt(ll))

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

rad_c = abs(h*30-m*5.5)
if rad_c > 180:
    rad_c = 360 - rad_c
c =  math.sqrt(a**2 + b ** 2 - (2 * b * a  * math.cos(math.radians(rad_c))))
print(c)

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

ax = A*math.cos(math.radians(HT))
ay = A*math.sin(math.radians(HT))
bx = B*math.cos(math.radians(MT))
by = B*math.sin(math.radians(MT))

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