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 sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): 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 LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]

def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]

def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)

MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

A,B,H,M = MI()
H_dig = 30*H + M/2
M_dig = 6*M
dif = H_dig-M_dig
dif = min(360-dif,dif)
rad = 2*math.pi*dif/360
dis = (A**2+B**2-2*A*B*math.cos(rad))**0.5
print(dis)

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

Solution (Python):
from math import pi,sqrt,cos
a,b,h,m=map(int,input().split())
theta1=360*(m/60)
theta2=360*(h/12)+360*(m/60)/12
theta=abs(theta2-theta1)
theta=min(theta,360-theta)*2*pi/360
c=sqrt(a**2+b**2-2*a*b*cos(theta))
print(c)

Solution (Python):
import numpy as np

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


hun_deg = m * 6

ji_deg = h * 30 + 30 * m / 60

hun_x = b * np.cos(hun_deg * np.pi / 180)
hun_y = b * np.sin(hun_deg * np.pi / 180)

ji_x = a * np.cos(ji_deg * np.pi / 180)
ji_y = a * np.sin(ji_deg * np.pi / 180)

out = np.sqrt((hun_x-ji_x)**2 + (hun_y-ji_y)**2)

print(out)

Solution (Python):
import math
A,B,H,M = map(int,input().rstrip().split(" "))
pi = math.pi
ans = 0
a_x = math.cos((H * 60 + M) / 360 * pi) * A
a_y = math.sin((H * 60 + M) / 360 * pi) * A
b_x = math.cos(M / 30 * pi) * B
b_y = math.sin(M / 30 * pi) * B
ans = math.sqrt(abs(a_x - b_x) ** 2 + abs(a_y - b_y) ** 2)
print(ans)

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

d1 = 30 * (H + M / 60)
d2 = M * 6
print(sqrt(A * A + B * B - 2 * A * B * cos(radians(abs(d1 - d2)))))

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

print(abs(a*cmath.exp(1j*(h+m/60)*cmath.pi/6)-b*cmath.exp(1j*m*2*cmath.pi/60)))

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

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b,h,m=mp()
print((a**2+b**2-2*a*b*math.cos(2*math.pi*(abs(h+m/60)/12-m/60)))**0.5)

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

X = (H+M*1/60)*30
Y = M*6
Z = min(abs(X-Y),abs(X+360-Y),abs(Y+360-X))
import math
cos = math.cos(math.radians(Z))
print((A**2+B**2-2*A*B*cos)**0.5)

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

long = (h * 60 + m) / 2
mini = 6 * m
ans = pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(abs(long - mini)/180 * math.pi)
print(ans ** 0.5)

Solution (Python):
import math

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

dh = 2 * math.pi * ((H + M / 60)/12)
dm = 2 * math.pi * (M/60)

dw = min((dh - dm) % (2 * math.pi), (dm - dh) % (2 * math.pi))
w = (A ** 2 + B ** 2 - 2 * A * B * math.cos(dw)) ** (1/2)

print(w)

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

def solve():
    input = sys.stdin.readline
    A, B, H, M = map(int, input().split())
    tMin = H * 60 + M
    hT = tMin * 0.5
    mT = 6 * M
    dT = abs(hT - mT)
    dT = min(dT, 360 - dT)
    diff = sqrt((A * cos(radians(dT)) - B) ** 2 + (A * sin(radians(dT))) ** 2)
    print(diff)

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
import math
con = 10 ** 9 + 7; INF = float("inf")

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


def main():
	A, B, H, M = getlist()
	x0 = A * math.cos(math.radians(30 * H + M * 0.5))
	y0 = A * math.sin(math.radians(30 * H + M * 0.5))
	x1 = B * math.cos(math.radians(6 * M))
	y1 = B * math.sin(math.radians(6 * M))
	ans = ((x1 - x0) ** 2 + (y1 - y0) ** 2) ** 0.5
	print(ans)

	
if __name__ == '__main__':
	main()

Solution (Python):
from math import *

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

theta_h = 2 * pi * ((h*60 + m) /(12*60))
theta_m = 2 * pi * (m/60)

theta = abs(theta_h-theta_m)

c_sq = a**2 + b**2 - 2*a*b*cos(theta) 
c = sqrt(c_sq)

print(c)

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

kaku1 = 360 *minu / (12*60)
kaku2 = 360 *minu / 60
kaku = max(abs(kaku1-kaku2),abs(kaku2-kaku1))

import math

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

Solution (Python):

import sys
import math

def solve(A: int, B: int, H: int, M: int):
    minRad = M/60*2*math.pi
    hourRad = (60*H+M)/(60*12)*2*math.pi
    minCoord = (B*math.cos(minRad),B*math.sin(minRad))
    hourCoord = (A*math.cos(hourRad),A*math.sin(hourRad))
    print(math.sqrt((minCoord[0]-hourCoord[0])**2+(minCoord[1]-hourCoord[1])**2))
    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):
a,b,h,m = map(int,input().split())
import math
theta1 = m*2*math.pi/60
theta2 = math.pi*2*h/12+math.pi*m/360

print((a*a+b*b-2*a*b*math.cos(abs(theta1-theta2)))**0.5)

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

da = (H + M / 60) * 30  
db = 6 * M
da = math.radians(da)
db = math.radians(db)

xa = A * math.cos(da)
ya = A * math.sin(da)
xb = B * math.cos(db)
yb = B * math.sin(db)

print(((xa-xb)**2+(ya-yb)**2)**0.5)

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

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

mm = m * 6
hh = (h + m / 60) * 30

ans = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(radians(abs(hh - mm))))
print(ans)

Solution (Python):
import math
import cmath

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

minuteTheta = 2.0 * math.pi * M / 60.0
hourTheta = 2.0 * math.pi * (H / 12.0 + M / (60.0 * 12.0))

mvec = cmath.rect(B, minuteTheta)
hvec = cmath.rect(A, hourTheta)

print(abs(mvec - hvec))

Solution (Python):
if __name__ == '__main__':
    from sys import stdin
    
    
    
    
    import math
    
    input = stdin.readline

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

    total_minutes = 60*h + m
    h_degree = total_minutes*0.5
    m_degree = 6*m
    difference = h_degree - m_degree
    if difference > 180:
        difference = 360 - difference
    print((a**2+b**2-2*a*b*math.cos(math.radians(difference)))**0.5)

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

t = h * 60 + m
th_a = (0.5 * t) % 360
th_b = (6.0 * t) % 360
th = min(abs(th_a - th_b), 360 - abs(th_a - th_b))

th = (th / 360) * (2 * math.pi)

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

Solution (Python):
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


A,B,H,M = nm()
(a, b, h, m)=map(float,(A,B,H,M))

theta = 2.0 * math.pi * ( m /60.0 - (h + m /60.0 )/12.0)
print(math.sqrt( a * a + b * b - 2.0 * a * b * math.cos(theta)))

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

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

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

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

H = radians((60 * H + M) * 360 / (12 * 60))
M = radians(M * 360 / 60)

print(((A * cos(H) - B * cos(M)) ** 2 + (A * sin(H) - B * sin(M)) ** 2) ** 0.5)

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

Hx = A*math.sin(math.radians(360*((H*60+M)/(12*60)))) 
Hy = A*math.cos(math.radians(360*((H*60+M)/(12*60)))) 
Mx = B*math.sin(math.radians(360*(M/60))) 
My = B*math.cos(math.radians(360*(M/60)))

print(((Hx-Mx)**2 + (Hy-My)**2)**(1/2))

Solution (Python):
import math

a,b,h,m = map(int,input().split())
m = m + 60*h
deg = (5.5 * m)%360
ans = (a - b * math.cos(math.radians(deg)))**2 + (b * math.sin(math.radians(deg)))**2
ans = ans**0.5

print(ans)

Solution (Python):
import sys, math
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, H, M = LI()

    rad_M = 2*math.pi * M / 60
    rad_H = 2*math.pi * (60*H+M) / 720

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

    print(ans)

if __name__ == '__main__':
    resolve()

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


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


def main():
    A, B, H, M = readnums()
    d = min(0.5 * (H * 60 + M) - 6 * M, 360 - (0.5 * (H * 60 + M) - 6 * M))
    print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(d))))


if __name__ == "__main__":
    main()

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

Solution (Python):

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

t = (30*H -5.5*M)/180 * np.pi
print((A**2 +B**2 -2*A*B*np.cos(t))**0.5)

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

Solution (Python):
import math

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

t=h*60+m

print(math.sqrt(
    a**2+b**2-2*a*b*math.cos(2*3.1415926535879*(t/60/12-t/60))
))

Solution (Python):
import math
def main():

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

    ang1 = H * 30 + (30/60) * M
    ang1 = (ang1/180) * math.pi
    x1 = A * math.cos(ang1)
    y1 = A * math.sin(ang1)


    ang2 = M * 6
    ang2 = (ang2/180) * math.pi
    x2 = B * math.cos(ang2)
    y2 = B * math.sin(ang2)

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


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

Solution (Python):
import math
PI = math.pi

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

rad_h = (h/12 + m/60/12) * 2 * PI
rad_m = m/60 * 2 * PI

ans = a**2 + b**2 - 2*a*b*math.cos(rad_h-rad_m)
print(ans**0.5)

Solution (Python):
import math

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

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

kakudo=abs(jido-hudo)



cosain=math.cos(math.radians(kakudo))
answer=(a**2+b**2-2*a*b*cosain)**0.5

print(answer)

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

    ht = (h/12+m/12/60)*2*math.pi
    mt = 2*math.pi*m/60
    if ht > mt:
        t = ht-mt
    else:
        t = mt-ht
    if t > math.pi:
        t = 2*math.pi-t
    c = a**2+b**2-2*a*b*math.cos(t)
    print(c**0.5)


main()

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

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

xa=a*cos(ta*pi/180)
ya=a*sin(ta*pi/180)

xb=b*cos(tb*pi/180)
yb=b*sin(tb*pi/180)

print(sqrt((xa-xb)**2+(ya-yb)**2))

Solution (Python):
from math import *
a, b, h, m = map(int, input().split())
t = h*60+m
a1 = 2*pi*t/(12*60)
a2 = 2*pi*m/60
x1, y1 = a*cos(a1), a*sin(a1)
x2, y2 = b*cos(a2), b*sin(a2)
res = ((x1-x2)**2+(y1-y2)**2)**0.5
print("%.12f" % res)

Solution (Python):
import numpy as np

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

def rot(deg):
    theta = np.radians(deg)
    c,s = np.cos(theta),np.sin(theta)
    return np.array([[c,-s],[s,c]])

print(np.linalg.norm(A*rot((H*60+M)*360/(60*12)).dot([[0],[1]]) - B*rot(M*360/60).dot([[0],[1]])))

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

c1 = 2 * math.pi * (M / 60)
c2 = 2 * math.pi * ((60*H+M)/720)

dif = abs(c1-c2)
dif = min(dif , 2*math.pi-dif)


print ( (A**2+B**2-2*A*B*math.cos(dif))**0.5 )

Solution (Python):
import math

a,b,h,m = map(int,input().split())
ra = 360*h/12+30*m/60
rb = 360*m/60
print((a**2+b**2-2*a*b*math.cos(math.radians(abs(ra-rb))))**0.5)

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

ho_theta = H*30 + M * 0.5
min_theta = M * 6

theta = math.radians(abs(ho_theta-min_theta))
C = A**2 + B**2 -2*A*B*(math.cos(theta))
print(math.sqrt(C))

Solution (Python):
import math

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

theta1 = (60*h+m)/360*math.pi
x1, y1 = a*math.cos(theta1), a*math.sin(theta1)
theta2 = m/30*math.pi
x2, y2 = b*math.cos(theta2), b*math.sin(theta2)

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

Solution (Python):







import math








import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    a,b,h,m=map(int,input().split())
    hval=h*30
    mval=m*6
    hval+=30*(m/60)
    val=min(abs(mval-hval),360-abs(mval-hval))
    print(math.sqrt(a**2+b**2-(2*a*b*math.cos(math.radians(val)))))

    
resolve()

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

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

theta_min = 2*math.pi/60*M
theta_hour = 2*math.pi/(60*12)*(H*60+M)

x1, y1 = A*math.cos(theta_hour), A*math.sin(theta_hour)
x2, y2 = B*math.cos(theta_min), B*math.sin(theta_min)
print(math.sqrt((x1-x2)**2+(y1-y2)**2))

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


fun_shin = M/60 * 2*pi
ji_shin = (60*H+M)/(12*60) * 2*pi

a2 = A**2 + B**2 - 2*cos(fun_shin-ji_shin) * A*B
print(a2**.5)

Solution (Python):
import numpy as np

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

alpha = 2 * np.pi * (H/12 + M/(60*12))
beta = 2 * np.pi * M/60

print(((A * np.cos(alpha) - B * np.cos(beta))**2 + (A * np.sin(alpha) - B * np.sin(beta))**2)**0.5)

Solution (Python):

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

time = h * 60 + m
theta_a = (360 / 720 * time) % 360
theta_b = (360 / 60 * time) % 360
theta = max(theta_a, theta_b) - min(theta_a, theta_b)
theta = math.radians(theta)
tmp = a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)
print(pow(tmp, 0.5))

Solution (Python):
import math
a,b,h,m = map(int,input().split())
pi = math.pi
x1 = a * math.sin(2 * pi * (h/12 + m/12/60))
y1 = a * math.cos(2 * pi * (h/12 + m/12/60))
x2 = b * math.sin(2*pi * m/60)
y2 = b * math.cos(2*pi * m/60)
print(math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2))

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

Solution (Python):
from math import pi, cos, sqrt
def main():
    A, B, H, M = map( int, input().split())
    ans = A**2 + B**2 - 2*A*B*cos((M/60 - (H/12+M/(12*60)))*2*pi)
    print(sqrt(ans))
if __name__ == '__main__':
    main()

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

def yogen(b, c, shi):
    return sqrt(b**2+c**2 - 2*b*c*cos(shi))

shi1 = radians(m / 60 * 360)
shi2 = radians((h * 60 + m)/(12*60)*360)

print(yogen(a, b, abs(shi1 - shi2)))

Solution (Python):
import math
import numpy as np
import queue
from collections import deque
import heapq

a,b,h,m = map(int,input().split())
deg = abs(h*30+m*0.5-m*6)
c2 = a**2+b**2-2*a*b*math.cos(math.radians(deg))
print(c2**(0.5))

Solution (Python):
import math
inpl = lambda: list(map(int,input().split()))
A, B, H, M = inpl()
angle_h = (H + M/60)/12 * (2 * math.pi)
angle_m = M/60 * (2 * math.pi)
angle = angle_h - angle_m
print(math.sqrt(A*A + B*B - 2*A*B*math.cos(angle)))

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, H, M = MAP()

t = 60*H+M
deg = 5.5 * t
deg = min(360-deg, deg)

rad = radians(deg)
c2 = A**2 + B**2 - 2*A*B*cos(rad)
print(c2**0.5)

Solution (Python):
import math


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

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

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

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

x = h * 30.0 + 0.5 * m - 6.0 * m
theta = min(x, 360.0 - x)
theta = math.radians(theta)

ans = a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)
print(ans ** 0.5)

Solution (Python):
import math

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


x = h*30+m/2
y = m*6
kakudo = max(x,y)-min(x,y)
kakudo = min(kakudo,360-kakudo)

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

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque 


from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush




def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)

def main():
    mod = 10**9+7
    

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


    t=M/60*2*math.pi
    s=2*math.pi*(M/12/60+H/12)
    x1=A*math.cos(s)
    y1=A*math.sin(s)
    x2=B*math.cos(t)
    y2=B*math.sin(t)
    ans=(x1-x2)**2+(y1-y2)**2
    print(ans**0.5)




if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math

a, b, h, m = map(int, input().split())
h = (h+m/60)/12*2*math.pi
m = m/60*2*math.pi
p1 = [a*math.cos(h), a*math.sin(h)]
p2 = [b*math.cos(m), b*math.sin(m)]
print(((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5)

Solution (Python):
import math

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

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

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

Solution (Python):
import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))



import math

a,b,h,m = readints()

p = math.pi

short = m*2*p/60
long = h*2*p/12 + m*2*p/12/60

deg = min(abs(short-long),2*p-abs(short-long))

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

print(ans)

Solution (Python):
from sys import stdin
import math


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,H,M = list(map(int,_in[0].split(' ')))  
    
    hour_ = (H+M/60)/12*(2*math.pi)
    min_ = M/60*(2*math.pi)
    theta = hour_ - min_
    cnt = math.sqrt(A**2+B**2-2*A*B*math.cos(theta))
    
    print(cnt)

Solution (Python):
import numpy as np
A,B,H,M=map(int,input().split())
sita1=np.pi*(M/30)
sita2=np.pi*(60*H+M)/360
print(np.sqrt(A**2+B**2-2*A*B*np.cos(sita2-sita1)))

Solution (Python):
a,b,h,m = map(int,input().split())
pi = 3.14159265358979323846
s = pi*m/30
t = pi*h/6 + pi*m/360
import math
diff = s - t
cos = math.cos(s-t)

print((a**2+b**2-2*a*b*cos)**.5)

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

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

theta_a = 2 * pi * (H%12)/12 + 2 * pi / 12 * M/60
theta_b = 2 * pi * M/60

theta = abs(theta_a - theta_b)

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

Solution (Python):


from math import pi
from math import sqrt
from math import cos
A, B, H, M = map(int, input().split())

m_degree = M * (pi / 30)

real_h  = H + M/60
h_degree = real_h * (pi / 6)

l = sqrt(A**2 + B**2 - 2*A*B*cos(abs(m_degree-h_degree)))
print(l)

Solution (Python):
import math

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

b_theta = m / 60 * 2 * math.pi
a_theta = (h * 60 + m) / 720 * 2 * math.pi
bx = b * math.cos(b_theta)
by = b * math.sin(b_theta)
ax = a * math.cos(a_theta)
ay = a * math.sin(a_theta)
dx = abs(ax - bx)
dy = abs(ay - by)
print(math.sqrt(dx ** 2 + dy ** 2))

Solution (Python):
import math

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

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

rad = abs(jisin_rad - hunsin_rad)

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

Solution (Python):

import sys
import cmath
from math import pi
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a,b,h,m=map(int,input().split())
    h%=12
    m%=60
    H=cmath.rect(a,(h/12+m/720)*2*pi)
    M=cmath.rect(b,m/60*2*pi)
    print(abs(H-M))

if __name__ == '__main__':
    main()

Solution (Python):
import math

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

t = H*60 + M

deg1 = t * 0.5 * math.pi / 180
deg2 = t * 6 * math.pi / 180

ans2 = A**2 + B**2 - 2*A*B*math.cos(deg1-deg2)
print(ans2**0.5)

Solution (Python):
import sys
input=sys.stdin.readline
a,b,h,m=map(int,input().split())
x=0.5*(60*h+m)
y=6*(60*h+m)
x=x%360
y=y%360
z=abs(x-y)
import math
z=math.radians(z)
ans=a**2+b**2-2*a*b*math.cos(z)
ans=math.sqrt(ans)
print(ans)

Solution (Python):
import math

A, B, H, M = map(int, input().split())
rad1 = math.pi / 6 * (H + (M / 60))
rad2 = math.pi * 2 * M / 60
rad = rad1 - rad2
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)) ** 0.5)

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

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

Solution (Python):
from math import *
A,B,H,M=map(int,input().split())
dh=(H*60+M)/720
dm=M/60
d=min(abs(dh-dm),1-abs(dh-dm))*2*pi
print((A**2+B**2-2*A*B*cos(d))**.5)

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


th=(h+m/60)*30-m*6
l=a**2+b**2-2*a*b*cos(radians(th))
print(l**(1/2))

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

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

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

Solution (Python):
def main():
    from math import cos, radians

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

    x = abs(H * 30 + 0.5 * M - 6 * M)
    x = radians(x)

    C = A * A + B * B - 2 * A * B * cos(x)
    C = pow(C, 0.5)

    print(C)


if __name__ == '__main__':
    main()

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

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

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

r1 = 2 * pi * (60 * H + M) / (12 * 60)
x1, y1 = A * cos(r1), A * sin(r1)

r2 = 2 * pi * M / 60
x2, y2 = B * cos(r2), B * sin(r2)

diff = (x1 - x2) ** 2 + (y1 - y2) ** 2
print(diff ** 0.5)

Solution (Python):
import math

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

if H >= 12:
    H = H - 12

nw = H * 30 + M * 0.5
mw = M * 6
ans = abs(nw - mw)
do = min(ans, 360-ans)


c2 = A**2 + B**2 - 2*A*B*math.cos(math.radians(do))
print(math.sqrt(c2))

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

th1 = (H + M / 60) / 12 * 2 * math.pi
th2 = M / 60 * 2 * math.pi
x1 = [A * math.cos(th1), A * math.sin(th1)]
x2 = [B * math.cos(th2), B * math.sin(th2)]
d = ((x1[0] - x2[0]) ** 2 + (x1[1] - x2[1]) ** 2) ** 0.5
print(d)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
theta1 = 2 * math.pi * (h + m / 60) / 12
theta2 = 2 * math.pi * m / 60
theta = abs(theta1 - theta2)
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)))

Solution (Python):
import numpy as np

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

T = H*60+M
r1 = T/(12*60) *2*np.pi
r2 = M/60 * 2*np.pi

P1 = A*np.array([np.cos(r1),np.sin(r1)])
P2 = B*np.array([np.cos(r2),np.sin(r2)])
print(np.linalg.norm(P1-P2))

Solution (Python):
import math


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

tyo = 360 * h / 12 + 30 * m / 60
tan = 360 * m / 60
theta = tyo - tan

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

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

    def dump(*args):
        sys.stderr.write(str(args))

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

    hun = m / 60 * 360
    zikan = h / 12 * 360 + hun / 12
    kakudo = abs(hun - zikan)
    import math
    c = a ** 2 + b ** 2 - 2 * a * b * math.cos(kakudo * math.pi / 180)
    print(c**0.5)


if __name__ == '__main__':
    main()

Solution (Python):
import math

def main():
    A, B, H, M = list(map(int, input().split()))
    at, bt = (H + M / 60) * 2 * math.pi / 12, M * 2 * math.pi / 60
    ax, ay = A * math.sin(at), A * math.cos(at)
    bx, by = B * math.sin(bt), B * math.cos(bt)

    return ((ax - bx) ** 2 + (ay - by) ** 2) ** 0.5

print(main())

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

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

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

th = 2 * pi * (h / 12) + (2 * pi / 12) * (m / 60)
tm = 2 * pi * (m / 60)

answer = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(th - tm))
print(answer)

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

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())



a,b,h,m = MI()
sit = abs(2 * math.pi *  m / 60 - 2 * math.pi * (60 * h + m) / 720 )
print(numpy.sqrt(a ** 2 + b ** 2 - 2 * a * b * numpy.cos(sit) ))

Solution (Python):
import math

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

short = M/60*2*math.pi
long = (H+M/60)/12*2*math.pi

theta = short - long

dist = (A**2 + B**2 -2*A*B*math.cos(theta))**0.5

print(dist)

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

import math
deg1 = h * 30 + m * 0.5
deg2 = 6 * m

co1 = [a * math.cos(math.radians(deg1)), a * math.sin(math.radians(deg1))]
co2 = [b * math.cos(math.radians(deg2)), b * math.sin(math.radians(deg2))]

d = (co1[0] - co2[0]) ** 2 + (co1[1] - co2[1]) ** 2
print(d ** 0.5)

Solution (Python):
import math
A,B,H,M = map(int,input().split())
ta = 2*math.pi * (M/60.0)
tb = 2*math.pi * (H/12.0 + M/720.0)
print((A**2.0+B**2.0-2.0*A*B*math.cos(ta-tb))**0.5)

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