Problem:
 Score: 300 points    Problem Statement  Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?      Constraints   All values in input are integers.  1 \leq A, B \leq 1000  0 \leq H \leq 11  0 \leq M \leq 59         Input  Input is given from Standard Input in the following format:  A  B  H  M       Output  Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9} .        Sample Input 1 3 4 9 0      Sample Output 1 5.00000000000000000000  The two hands will be in the positions shown in the figure below, so the answer is 5 centimeters.        Sample Input 2 3 4 10 40      Sample Output 2 4.56425719433005567605  The two hands will be in the positions shown in the figure below. Note that each hand always rotates at constant angular velocity.

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

argH = 30 * (H + M / 60)
argM = 6 * M
arg = abs(argH - argM - 180)
length = math.sqrt( A**2 + B**2 - 2*A*B*math.cos(math.radians(argH - argM)))
print(length)

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



import math
x1 = a*math.sin(math.radians(30*h+30*m/60))
y1 = a*math.cos(math.radians(30*h+30*m/60))

x2 = b*math.sin(math.radians(6*m))
y2 = b*math.cos(math.radians(6*m))



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

print(ans)

Solution (Python):
import math

import sys

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

a,b,h,m = map(int,input().split())
l = [math.cos(m*math.pi/30) * b, math.sin(m*math.pi/30) * b]
t = math.pi * (h*60 + m) / 360
s = [math.cos(t) * a, math.sin(t) * a]
print(math.sqrt((l[0]-s[0])**2 + (l[1]-s[1])**2))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
a,b,h,m = map(int, input().split())

import math

h_rad = 30*(h+m/60)
m_rad = 6*m
diff_rad = min(abs(h_rad-m_rad),360-abs(h_rad-m_rad))
cos = math.cos(math.radians(diff_rad))

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

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

thetaA = M / 60 * 2 *np.pi
thetaB = (H+M/60) / 12 * 2 *np.pi
theta = thetaA - thetaB if thetaA >= thetaB else thetaB - thetaA
if theta > 180:
    theta = 180 - theta 

c = np.sqrt(A**2 + B**2 - 2 * A * B * np.cos(theta))

print(c)

Solution (Python):

"""
@author: H_Hoshigi
"""

import math

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

def main():
    A, B, H, M = map(int, input().split())
    theta1 = (60*H + M) * math.pi / 360
    theta2 = M * math.pi / 30
    x1 = A * math.sin(theta1)
    y1 = A * math.cos(theta1)
    x2 = B * math.sin(theta2)
    y2 = B * math.cos(theta2)
    print(dist(x1, y1, x2, y2))

if __name__ == "__main__":
    main()

Solution (Python):
import math

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

hun = 6*m
zi = 30*h + m/2

diff = abs(hun-zi)
if diff > 180:
    diff = 360-diff
    


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

Solution (Python):
import math

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


def kaiten(n):
    return math.cos((n / 180) * math.pi), math.sin((n / 180) * math.pi)


xx, xy = kaiten(30 * h + 0.5 * m)
xx *= a
xy *= a

yx, yy = kaiten(6 * m)
yx *= b
yy *= b
kyori = math.sqrt((xx - yx) ** 2 + (xy - yy) ** 2)
print(kyori)

Solution (Python):

import math
import sys

sys.setrecursionlimit(10 ** 7)



INF = float("inf")
MOD = 10 ** 9 + 7


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


short = H * 360 / 12 + M / 2
long = M * 360 / 60

angle = abs(short - long)
angle = min(angle, 360-angle)

radian = math.pi*angle/180
ans = math.sqrt((A**2+B**2-2*A*B*math.cos(radian)))

print(ans)

Solution (Python):
import sys
import math as m
A,B,H,M = list(map(int, sys.stdin.readline().rstrip().split())) 

aH = ((H%12)*60 + M)/720
aM = M/60
angle = max(aH,aM) - min(aH,aM)
angle*2*m.pi


ans = A**2 + B**2 - 2*A*B*m.cos(angle*2*m.pi)
ans = ans**0.5
print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
bb=6*m
aa=0.5*m+30*h
if aa<bb:
    cc=aa
    aa=bb
    bb=cc
sum_=aa-bb
if 180<=sum_:
    sum_=360-sum_
si=math.radians(sum_)
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(si))
print(ans)

Solution (Python):
import math
data = list(map(int,input().split()))
A = data[0]
B = data[1]
H = data[2]
M = data[3]
degree = abs(30 * H + 0.5 * M - 6 * M )
rad = math.radians(degree)
ab = A * A + B * B - 2 * A * B * math.cos(rad) 
print(math.sqrt(ab))

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

theta_H=2*math.pi*(H/12+M/720)
theta_M=2*math.pi*M/60


ax,ay=A*math.sin(theta_H),A*math.cos(theta_H)
bx,by=B*math.sin(theta_M),B*math.cos(theta_M)


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

Solution (Python):
import math

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

hour_deg = (h + m / 60) / 12 * 360
min_deg = (m / 60) * 360

deg_diff = abs(min_deg - hour_deg)
ans = a**2 + b**2 - (2 * a * b * math.cos(math.radians(deg_diff)))
print(math.sqrt(ans))

Solution (Python):
import math

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

aaa = h * 30 + m * 0.5
bbb = m * 6
ccc = aaa - bbb

if ccc < -180:
	ccc += 360
elif ccc > 180:
	ccc = 360 - ccc
else:
	ccc = abs(ccc)
	
ddd = ccc * math.pi / 180
eee = a ** 2 + b ** 2 - 2 * a * b * math.cos(ddd)

print(eee ** (1/2))

Solution (Python):
import numpy as np 

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

ab_time = h + (m / 60)
rad_a = np.pi * ab_time / 6
rad_b = np.pi * ab_time * 2
rad_ab = rad_b - rad_a

ll = a**2 + b**2 - 2 * a * b * np.cos(rad_ab)
l = ll**0.5

print(str(l))

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

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

d = abs(30*H - 5.5*M)
c = sqrt(A*A + B*B - 2*A*B*cos(radians(d)))

print(c)

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

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

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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    a,b,h,m = inpm()
    e = (m/30)*math.pi
    f = (h/6)*math.pi + (math.pi/6)*(m/60)
    x1,y1 = b*math.cos(e),b*math.sin(e)
    x2,y2 = a*math.cos(f),a*math.sin(f)
    print(((x1-x2)**2+(y1-y2)**2)**(1/2))
    
if __name__ == "__main__":
    main()

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

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

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

cos = math.cos(math.radians(6 * M - 0.5 * (H * 60 + M)))

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

Solution (Python):
from math import radians
from math import cos
def main():
    a, b, h, m = map(int, input().split())
    a_kaku = 30 * (h % 12) + 0.5 * m
    b_kaku = 6 * m
    kakudo = abs(a_kaku - b_kaku)
    coskaku = cos(radians(kakudo))
    r2 = a**2 + b**2 - (2 * a * b * coskaku)
    print(r2 ** 0.5)

if __name__ == '__main__':
    main()

Solution (Python):
import math
A, B, H, M = [int(x) for x in input().split()]
h = 360 * (H + M/60) / 12
m = 360 * M / 60
cos = math.cos(math.radians(abs(h-m)))
ans = math.sqrt(A*A + B*B - 2*A*B*cos)
print(ans)

Solution (Python):
import math

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

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

kaku_b = 360 * (M/60)

kaku_c = abs(kaku_a - kaku_b)
if kaku_c > 180:
    kaku_c = 360 - kaku_c

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

print(ans)

Solution (Python):
import math

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

    ans = (A**2 + B ** 2 - 2 * A * B * math.cos(abs(math.radians(360*H/12) + math.radians(30 * M / 60) - math.radians(360*M/60)))) ** 0.5

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys


import math
import collections





import copy

import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
MOD2 = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





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

    short_deg = (h * 30 + 30 * m / 60)
    long_deg = 6 * m

    short_x = a * math.sin(math.radians(short_deg))
    short_y = a * math.cos(math.radians(short_deg))
    long_x = b * math.sin(math.radians(long_deg))
    long_y = b * math.cos(math.radians(long_deg))

    ans = ((short_x - long_x) ** 2 + (short_y - long_y) ** 2) ** (1 / 2)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import math
a,b,h,m=(int(x) for x in input().split())
hk=30*h+1/2*m
mk=6*m
kakudo=hk-mk
if kakudo>180:
    kakudo=360-kakudo
print((a**2+b**2-2*a*b*(math.cos(math.radians(kakudo))))**(1/2))

Solution (Python):
def inputs(): return [int(x) for x in input().split()]
import math
a,b,h,m=inputs()
sita1 = m/2+30*h
sita2 = 6*m
sita = min(abs(sita1-sita2),360-abs(sita1-sita2))
ans =(a**2+b**2-2*a*b*math.cos(sita/180*math.pi))**0.5
print(ans)

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

minutes = 60*h+min

degree_long = minutes*.5
degree_short = minutes*6 % 360


class P:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __sub__(self, q):
        return P(self.x-q.x, self.y-q.y)

    def length(self):
        return m.sqrt(self.x**2+self.y**2)


v1 = P(a*m.cos(m.radians(degree_long)), a*m.sin(m.radians(degree_long)))
v2 = P(b*m.cos(m.radians(degree_short)), b*m.sin(m.radians(degree_short)))

v3 = v1-v2
print(v3.length())

Solution (Python):
import math
import numpy

a,b,h,m = (float(x) for x in input().split())
hkaku = 360 * h / 12 + 30 * m / 60
mkaku = 360 * m / 60
kakudo = abs(hkaku-mkaku) * math.pi * 2 / 360
x = a*a + b*b - 2*a*b*math.cos(kakudo)
x = x**0.5
print(x)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
theta_a = (h % 12) * 30 + 0.5 * m
theta_b = 6 * m
theta = theta_a - theta_b
if theta > 180:
    theta = 360 - theta

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

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

minutes = 60*h + m
rada = minutes*360/(60*12)*math.pi/180
radb = m*360/60*math.pi/180


ax,ay = a*math.cos(rada), a*math.sin(rada)
bx,by = b*math.cos(radb), b*math.sin(radb)

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

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

kakuA = 30 * H + 30 * M / 60
kakuB = 360 * M / 60

dkaku = abs(kakuA - kakuB)
dkaku = min(dkaku, 360 - dkaku)
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(dkaku))))

Solution (Python):
import math
a,b,h,m=map(int,input().split())
c=h*60+m
d=(5.5*c)%360
num=0
if d>180:
    num=360-d
else:
    num=d
if num==0:
    print(abs(a-b))
elif num==180:
    print(a+b)
else:
    num2=(a*a)+(b*b)
    num3=(math.cos(math.radians(num)))*a*b*-2
    print(math.sqrt(num2+num3))

Solution (Python):
import math
import numpy as np

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

past = 60.0*H + M
half_day = 12*60.0

omega_long = past/half_day
omega_short = M/60.0





omega = np.abs(omega_long - omega_short)
omega = 2*np.pi*omega

ans = np.sqrt(math.pow(B*np.sin(omega),2) + math.pow((A-B*np.cos(omega)),2))

print(ans)

Solution (Python):
import math

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

lx=b*math.cos(math.radians(6*m))
ly=b*math.sin(math.radians(6*m))
sx=a*math.cos(math.radians((60*h+m)*0.5))
sy=a*math.sin(math.radians((60*h+m)*0.5))

length=((lx-sx)**2+(ly-sy)**2)**(1/2)
print(length)

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

Solution (Python):
import math

def abc168_c():
    A, B, H, M = map(int, input().split())
    
    h_angle = 30 * H + 0.5 * M
    
    m_angle = 6 * M
    
    x_dist = A * math.cos(math.radians(h_angle)) - B * math.cos(math.radians(m_angle))
    
    y_dist = A * math.sin(math.radians(h_angle)) - B * math.sin(math.radians(m_angle))
    
    dist = math.sqrt(x_dist ** 2 + y_dist ** 2)
    print('{:.12f}'.format(dist))

abc168_c()

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


b = (M * 6) % 360
H += M/60
a = (H * 30) % 360
deg = abs(a - b)

theta = math.radians(deg)


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

print(cc**0.5)

Solution (Python):
import math

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

angle = abs((H/12+M/720)%1 - (M/60)%1) * 2 * math.pi
cos = math.cos(angle)

print((A*A+B*B-2*A*B*cos)**0.5)

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

H_deg = (60*H+M)*0.5
M_deg = M*6
H_rad = math.radians(H_deg)
M_rad = math.radians(M_deg)

theata = abs(H_rad-M_rad)
if(theata == 0):
  ans = abs(A-B)
else:
  C = A*A+B*B-2*A*B*math.cos(theata)
  ans = math.sqrt(C)
  
print(ans)

Solution (Python):
import math
import queue
from collections import defaultdict
import itertools as it

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1

a,b,h,m = readInts()

sa = 30*h+m*0.5
sb = m*6

cal = (a*math.sin(math.radians(sa))-b*math.sin(math.radians(sb)))**2+(a*math.cos(math.radians(sa))-b*math.cos(math.radians(sb)))**2

print(cal**0.5)

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

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
p = math.pi
kaku_a = 2*p*(h*60+m)/(12*60)
kaku_b = 2*p*m/60
beta = abs(kaku_a-kaku_b)
c = math.sqrt(pow(a,2)+pow(b,2)-2*a*b*math.cos(beta))
print(c)

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

s_1=h/12*360+m/60*30
s_2=m/60*360
s=s_1-s_2
ans=0
if abs(s)==180:
    print(a+b)
    exit()

if abs(s)<180:
    s=s
else:
    s=360-s

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

print(ans)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    A, B, H, M = Scanner.map_int()
    S = 30 * H + 30 / 60 * M
    S = S / 180 * math.pi
    sx, sy = math.cos(S) * A, math.sin(S) * A

    T = 6 * M
    T = T / 180 * math.pi
    tx, ty = math.cos(T) * B, math.sin(T) * B
    x, y = tx - sx, ty - sy
    l = (x ** 2 + y ** 2) ** 0.5
    print(l)


def main():
    
    solve()


if __name__ == "__main__":
    main()

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

import math

kakua = (h/12+m/60/12)*2*math.pi
kakub = m/60 * 2*math.pi


c = (a**2.0+b**2.0 - 2.0*a*b*math.cos(kakua-kakub)) ** 0.5
print(c)

Solution (Python):
import math

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

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

if theta_a <= theta_b:
    theta = theta_b - theta_a
else:
    theta = theta_a - theta_b

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

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

long_x=math.cos(math.radians((H%12)*30+0.5*M))
long_y=math.sin(math.radians((H%12)*30+0.5*M))

short_x=math.cos(math.radians(M*6))
short_y=math.sin(math.radians(M*6))


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

d = get_distance(long_x*A, long_y*A, short_x*B, short_y*B)
print(d)

Solution (Python):
import math

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

t = 2*math.pi
x1 = m*t/60
x2 = h*t/12+m*t/12/60
c = abs(x1-x2)
s = a*a+b*b-2*a*b*math.cos(c)
print("%.20f" %math.sqrt(s))

Solution (Python):
import math
a, b, h, m = map(int, input().split())
theta = abs((360 * (h * 60 + m)/(12 * 60)) - (360 * m/60))

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

Solution (Python):
import math
a,b,h,m=map(float,input().split())
h=h*math.pi/6.0
h=h+m/60*math.pi/6.0
m=m*math.pi/30.0
t=min(2*math.pi-abs(h-m),abs(h-m))
c=(a*a+b*b-2*a*b*math.cos(t))**0.5
print(c)

Solution (Python):
import math
A, B, H, M =  map(int, input().split())
alpha = (H * 30 + M / 60.0 * 30) 
beta = (360.0 * M / 60) 
theta = abs(alpha - beta)
if theta > 180.0:
    theta = 360.0 - theta
theta = theta * math.pi / 180.0
c = A * A + B * B - 2 * A * B * math.cos(theta)
c = math.sqrt(c)

print(c)

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

Solution (Python):
from math import cos, radians

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


h = (h * 30) + (m * 0.5)
m *= 6
A = abs(h - m)
ans_p = a ** 2 + b ** 2 - 2 * a * b * cos(radians(A))
ans = ans_p ** 0.5
print(f"{ans:.9f}")

Solution (Python):
import math

a,b,h,m = map(int, input().split())
huna = m*6
zia = (60*h + m)*0.5
sita = 0.0
if huna >= zia:sita = huna - zia
else:sita = zia - huna

if sita > 90:sita = 360 - sita
ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(sita)))**0.5
print('{:.20f}'.format(ans))

Solution (Python):
import math
a, b, h, m = map(int, input().split(" "))
h_ = h*360/12 + m*360/12/60
m_ = m*360/60

sub = abs(h_ - m_)
c_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(sub))
print(math.sqrt(c_2))

Solution (Python):

import math

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

_b = m*6
_a = (h*60+m)/2

_k = abs(_a - _b)

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

print(ans)

Solution (Python):



import math


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

    m_t = h * 60 + m
    a_theta = - (m_t / (12 * 60) * (2 * math.pi))
    b_theta = - (m / 60 * (2 * math.pi))

    ax, ay = a * math.cos(a_theta), a * math.sin(a_theta)
    bx, by = b * math.cos(b_theta), b * math.sin(b_theta)

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


if __name__ == '__main__':
    main()

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    a, b, h, m = LI()
    mdeg = 6 * m
    hdeg = 30 * h + (m / 60) * 30
    if hdeg > mdeg:
        diff = hdeg - mdeg
    else:
        diff = mdeg - hdeg
    diff = min(diff, 360 - diff)
    rad = diff * math.pi / 180
    c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad))
    print(c)


main()

Solution (Python):
import math
A,B,H,M=map(float,input().split())
l=math.sqrt(A**2+B**2-2*A*B*math.cos((660*H+11*M)*math.pi/360))
print(l)

Solution (Python):
import math


a, b, h, m = map(int, input().split())
m_dig = 6*m
h_dig = 30*h + m*0.5
angle = abs(m_dig-h_dig)
cosa = math.cos(math.radians(angle))
ans_2 = a**2 + b**2 - 2*a*b*cosa
print(math.sqrt(ans_2))

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


B_x=math.cos(math.radians(6*M))*B
B_y=math.sin(math.radians(6*M))*B


A_x=math.cos(math.radians(0.5*(60*H+M)))*A
A_y=math.sin(math.radians(0.5*(60*H+M)))*A

kyori=((A_x-B_x)**2+(A_y-B_y)**2)**0.5

print(kyori)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
hours = H / 12 * (2 * math.pi) + M / 60 * (math.pi / 6)
minutes = M / 60 * (2 * math.pi)
theta = 0
if hours >= minutes:
    theta = hours - minutes
else:
    theta = minutes - hours
if theta > math.pi:
    theta = math.pi*2 - theta
c = math.sqrt(A*A + B*B - 2*A*B*math.cos(theta))
print(c)

Solution (Python):


def input_one_number():
    return int(input())

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

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

import math
PI = math.pi

A,B,H,M = input_multiple_number()

HHrad = 2*PI/12*H + 2*PI/12/60*M
MMrad = 2*PI*M/60

ans = pow(A**2 + B**2 -2*A*B*math.cos(HHrad-MMrad),0.5)

print(ans)

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

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

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

Solution (Python):
import math


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

a_rad = (H * 60 + M) * pi / 360
b_rad = M * pi / 30
rad = abs(a_rad - b_rad)
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(rad))
print(ans)

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

A,B,H,M=(int(x) for x in input().rstrip('\n').split())

x=6*M
y=H*30+M*0.5
si=math.pi*(x-y)/180
print(math.sqrt(A**2+B**2-2*A*B*math.cos(si)))

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

Solution (Python):
import math
a,b,c,d= list(map(int, input().split()))
c_kakudo=c*30+(0.5*d)
d_kakudo=d*6
kakudo=abs(c_kakudo-d_kakudo)
rad=(kakudo*math.pi)/180
ans=math.sqrt((a**2)+(b**2)-2*a*b*math.cos(rad))
print(ans)

Solution (Python):
import math
t = input().split(" ")
A, B, H, M = [int(te) for te in t]

mins = H * 60 + M

l = mins * 0.5
s = M * 6

c2 = A*A + B*B - 2*A*B*math.cos(math.radians(abs(l-s)))

print(pow(c2,0.5))

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

Solution (Python):


import numpy as np

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


time = 60*H + M

jishin_deg_perM = 2*np.pi / 720

jishin_coord  = np.array([A * np.cos(jishin_deg_perM*time), A * np.sin(jishin_deg_perM*time)])

funshin_deg_perM =  2*np.pi / 60

funshin_coord  = np.array([B * np.cos(funshin_deg_perM*M), B * np.sin(funshin_deg_perM*M)])

print(np.linalg.norm(jishin_coord-funshin_coord))

Solution (Python):
import math

s = input().split()

A = int(s[0])
B = int(s[1])
H = int(s[2])
M = int(s[3])

mi = 6 * M
ho = 30 * H + 1/2 * M

kakudo = abs(mi - ho)

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

print(length)

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

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

hm = h*60 + m
hdr = pi * (90 - hm * 0.5) / 180

x1 = a * math.cos(hdr)
y1 = a * math.sin(hdr)

mdr = pi * (90 - m * 6) / 180

x2 = b * math.cos(mdr)
y2 = b * math.sin(mdr)

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

Solution (Python):
import math

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

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

Solution (Python):
A,B,H,M=map(int, input().split())
import math
by=B*math.sin(math.radians(90-6*M))
bx=B*math.cos(math.radians(90-6*M))
ay=A*math.sin(math.radians(90-0.5*(H*60+M)))
ax=A*math.cos(math.radians(90-0.5*(H*60+M)))

d=(ax-bx)**2+(ay-by)**2
print(d**0.5)

Solution (Python):
import math


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

jishin = [0.0, A]
hunshin = [0.0, B]
angle_ji = (H + (M / 60)) / 12 * 2 * math.pi
angle_hun = (M / 60) * 2 * math.pi

def func(x,y, ang):
    return (math.cos(ang) * x - math.sin(ang) * y, math.sin(ang) * x + math.cos(ang) * y)

nxt_ji_x, nxt_ji_y = func(0.0, A, angle_ji)
nxt_hu_x, nxt_hu_y = func(0.0, B, angle_hun)

ans = math.sqrt(abs(nxt_ji_x - nxt_hu_x)**2 + abs(nxt_ji_y - nxt_hu_y)**2)
print(ans)

Solution (Python):
import math

a,b,h,m = map(float, input().split())
theta1 = (h*60 + m)/2
theta2 = m*6
theta = theta1 - theta2
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(theta)))
print(c)

Solution (Python):
def main():
    import math
    import numpy as np
    A, B, H, M = [int(x) for x in input().split()]

    omegaA = 2*math.pi / (60*12)
    omegaB = 2*math.pi / 60
    t = H*60 + M
    thetaA = omegaA*t
    thetaB = omegaB*t

    pA = np.array([np.cos(thetaA), np.sin(thetaA)]) * A
    pB = np.array([np.cos(thetaB), np.sin(thetaB)]) * B

    ans = np.linalg.norm(pA-pB)
    print(float(ans))
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

Solution (Python):


import math


def rotate(x, y, theta):
    """
    (x, y)をtheta回転時計回りに回転させる
    thetaはdegree
    """
    r = -math.radians(theta)
    new_x = x * math.cos(r) - y * math.sin(r)
    new_y = x * math.sin(r) + y * math.cos(r)
    return new_x, new_y


def submit():
    a, b, h, m = [int(e) for e in input().split()]
    minutes = h * 60 + m
    theta_a = 360 * minutes / (12 * 60)
    theta_b = 360 * minutes / 60

    point_a = rotate(0, a, theta_a)
    point_b = rotate(0, b, theta_b)

    dist = (point_a[0] - point_b[0]) ** 2 + (point_a[1] - point_b[1]) ** 2
    print(math.sqrt(dist))


if __name__ == "__main__":
    submit()

Solution (Python):
import math

A, B, H, M = map(int, input().split())
minute = H * 60 + M
hour_rad = 0.5 * minute
min_rad = 6 * M
if abs(hour_rad - min_rad) > 180:
    rad = 360 - abs(hour_rad - min_rad)
else:
    rad = abs(hour_rad - min_rad)

answer = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(rad)))
print(answer)

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

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

def main():
    d = 6 * m 
    c = 30 * (h + m / 60)
    theta = abs(d - c)
    ans = sqrt(a ** 2 + b ** 2 - 2*a*b*cos(theta * 2 * pi / 360))
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import heapq
import math

def main():
    a, b, h, m = map(int, input().split())
    angle = (math.pi / 30) * m - (m * math.pi / 360 + h * math.pi / 6)
    if angle < 0:
        angle = -angle
    ans = math.sqrt(a * a + b * b - 2 * b * a * math.cos(angle))
    print(ans)
    return

if __name__ == "__main__":
    main()

Solution (Python):
import math

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

theta=(60*h-11*m)/2


print(math.sqrt(max(0,a*a+b*b-2*a*b*math.cos(math.radians(theta)))))

Solution (Python):
import math
A,B,H,M= map(int, input().split())
T = 60 * H + M
d = T * 5.5 % 360
Long = H * 0.5
Short = M * 6
ans = A**2 + B**2 -2 * A * B * math.cos(math.radians(d))
print(math.sqrt(ans))