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

A_angle=H*30+0.5*M
B_angle=M*6

angle=math.radians(abs(A_angle-B_angle))

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

print(ans)

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

c = (60*h+m)/2
d = 6*m
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*(c-d)/180))
print(ans)

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

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

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

Solution (Python):
import math

a = input()
hour_length, minute_length, hours, minutes = [int(s) for s in a.split()]

hour_degrees = (hours + minutes / 60) * 360 / 12
hour_radians = math.radians(hour_degrees)
hour_x, hour_y = hour_length * math.sin(hour_radians), hour_length * math.cos(hour_radians)


minute_degrees = minutes * 360 / 60
minute_radians = math.radians(minute_degrees)
minute_x, minute_y = minute_length * math.sin(minute_radians), minute_length * math.cos(minute_radians)

distance = math.sqrt((hour_x - minute_x) ** 2 + (hour_y - minute_y) ** 2)
print(distance)

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

if __name__ == '__main__':
    main()

Solution (Python):
import math

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

tmi = h * 60 + m

a_dig = tmi*((360) / (12 * 60))
b_dig = tmi*((360) / (60))

diff = a_dig - b_dig


r = math.radians(diff)


s = b * math.sin(r)
c = b * math.cos(r)

dist = math.sqrt((a - c) ** 2 + s ** 2)
print(dist)

Solution (Python):
import math
a,b,h,m = map(int,input().split())
minutes = 60*h + m
c1 = (minutes /2)%360
c2 = (minutes * 6)%360
if c1==c2:
    print(abs(a-b))
else:
    if c1 > c2:
        p = min(c1-c2, 360-c1+c2)
    else:
        p = min(c2-c1, 360-c2+c1)    
    x = a**2 + b**2 - 2*a*b*math.cos(math.radians(p))
    print(x ** 0.5)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
a = 0.5 * (H * 60 + M) % 360
b = 6 * (H * 60 + M) % 360
c = math.cos(math.radians(a-b))
C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * c)
print(C)

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

r2=math.radians(360*m/60)
r1=math.radians(30*h)+r2/12
x1,y1=(a*math.cos(r1),a*math.sin(r1))
x2,y2=(b*math.cos(r2),b*math.sin(r2))

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

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


theta_min=(360/60)*M
theta_hour=(360/12)*(H+M/60)
theta=abs(theta_min-theta_hour)
print( math.sqrt(A**2+B**2 - 2*A*B*math.cos(math.radians(min(theta,360-theta)))) )

Solution (Python):
from math import cos, radians

A, B, H, M = map(int, input().split())
temp = abs(30 * H + 0.5 * M - 6 * M)
deg = min(temp, 360 - temp)
d = (A**2 + B**2 - 2*A*B*cos(radians(deg))) ** 0.5
print(d)

Solution (Python):
import math
a, b, h, m = map(int, input().split())
t = abs((h+m/60)*math.pi/6 - m*math.pi/30)

t = max(t, 2*math.pi-t)
cc = a*a + b*b - 2*a*b*math.cos(t)
print(cc**(1/2))

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

import math
Ar=H*30+M*0.5
Br=M*6
l=(A**2+B**2-2*A*B*math.cos(math.radians(abs(Ar-Br))))**0.5
print(l)

Solution (Python):
import math

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

theta_a = (60 * H + M) / 720
theta_b = M / 60
cos_c = math.cos(2 * (theta_a - theta_b) * math.pi)
c = (A**2 + B**2 - (2 * A * B * cos_c)) ** 0.5

print(c)

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

if h / 12 + m / 360 >= m / 60:
	dif = min(h / 12 + m / 720 - m / 60, 1 + m / 60 - h / 12 - m / 720)
else:
	dif = min(1 + h / 12 + m / 720 - m / 60, m / 60 - h / 12 - m / 720)

ans_sq = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(dif * 360))
print(math.sqrt(ans_sq))

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

import math 

x = A**2+B**2-2*A*B*math.cos(math.radians(11*M/2-30*H))

print(math.sqrt(x))

Solution (Python):
def main():
  import math
  A, B, H, M = map(int, input().split())
  kaku = abs( 360*(H/12) + 30*(M/60)  - 360*(M/60) )
  
  nagasa = math.sqrt(A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(kaku)))
  print(nagasa)
main()

Solution (Python):
import math

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

kaku_a = (math.pi * (h + m/60))/6
kaku_b = (math.pi * m / 5)/6

sub = kaku_a - kaku_b

if sub > 0:
    xx = a**2 + b**2 - 2*a*b*math.cos(sub)
else:
    xx = a**2 + b**2 - 2*a*b*math.cos(-1 * sub)

print(math.sqrt(xx))

Solution (Python):
import math

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

thA = math.pi*(H/6 + M/360)
thB = math.pi*M/30

C = math.sqrt(A**2 + B**2 -2*A*B*math.cos(abs(thA - thB)))

print(C)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
rshort = H * (360 / 12) + M / 2;
rlong = M * (360 / 60)
ang = abs(rlong - rshort)
ang = min(ang, 360 - ang)
rad = ang * math.pi / 180
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad))
print(ans)

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

import math

a_rad = (h+m/60)/12*2*math.pi
b_rad = m/60*2*math.pi



x_a, y_a = a*math.sin(a_rad), a*math.cos(a_rad)
x_b, y_b = b*math.sin(b_rad), b*math.cos(b_rad)




print(math.sqrt((x_a - x_b)**2 + (y_a - y_b)**2))

Solution (Python):



import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf



import math

import bisect



if __name__ == '__main__':
    b, c, h, m = list(map(int, input().split()))
    angle_h = (h * 60 + m) / (12 * 60)
    anble_m = m / 60
    angle = abs(angle_h - anble_m) * 360

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

Solution (Python):
"""    Arnab Chanda    """

from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

from math import sqrt,cos, pi

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7

def calcAngle(h,m): 

        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) 
          
        return angle 

a,b, h, m = multi_int_input()

angle = calcAngle(h, m)*(pi/180)



print(sqrt( a*a + b*b - 2*a*b*cos(angle)))

Solution (Python):
from math import *
a,b,h,m=map(int,input().split())
c=abs(m*11/720-h/12)
c*=360
c=min(c,abs(c-360))
ans=a**2+b**2-2*a*b*cos(radians(c))
print(ans**(1/2))

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

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

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

Solution (Python):
import math
a,b,h,m=map(int,input().split())
ra=6*m
rb=(60*h+m)/2
deg = rb-ra
if deg>180:
    deg = 360-deg
cos = math.cos(math.radians(deg))
res2 = a**2+b**2-2*a*b*cos
print(math.sqrt(res2))

Solution (Python):

import numpy as np
from collections import deque
import collections
import heapq

pi = 3.14159265359

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

hun = h*60+m

long_deg = ((360/60)*hun) % 360
short_deg = ((360/(12*60))*hun) % 360
diff = min(abs(long_deg - short_deg), 360-abs(long_deg - short_deg))
diff = np.deg2rad(diff)
ans = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(diff))

print(ans)

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

import math

h = H * math.pi/6 + M * math.pi/360
m = M * math.pi /30

theta = abs(h-m)

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

Solution (Python):
import math
a, b, h, m = map(int, input().split())
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)
dis = (a**2 + b**2 - 2*a*b*math.cos(math.radians(angle)))
dis = dis**(0.5)
print("{0:.12f}".format(dis))

Solution (Python):
import math
A, B ,H, M = map(int,input().split())
t = M / 60
c = (H * 60 + M)/720
t *= 360
c *= 360
d = abs(t-c)
rad = min(360-d,d)
COS = math.cos(math.radians(rad))
C = A**2 + B**2 - 2*A*B*COS
print(math.sqrt(C))

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

mins = H * 60 + M


diff_s = 5.5


tmp = diff_s * mins % 360
diff = min(tmp, 360 - tmp)


diff = math.radians(diff)


a2 = A**2 + B**2 - 2 * A * B * math.cos(diff)
ans = a2**0.5

print(ans)

Solution (Python):

from __future__ import division, print_function

import os
import sys
import math
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


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

    minute_angle = m * 2 * math.pi / 60
    hour_angle = h * 2 * math.pi / 12 + minute_angle / 12

    x = (math.cos(minute_angle) * a - math.cos(hour_angle) * b)
    y = (math.sin(minute_angle) * a - math.sin(hour_angle) * b)

    print((x ** 2 + y ** 2) ** 0.5)




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
import math
A, B, H, M = map(int, input().split())
h_d = H * 30
h_d += 30 * (M/60)
m_d = M * 6
d = min(360-abs(h_d-m_d), abs(h_d-m_d))
c = A*A+B*B-2*A*B*math.cos(math.radians(d))
print(math.sqrt(c))

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

a=math.radians(M*0.5+H*30)
b=math.radians(6*M)


ans2=(A*math.cos(a)-B*math.cos(b))**2+(A*math.sin(a)-B*math.sin(b))**2
ans=math.sqrt(ans2)
print(ans)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
h = H / 12 * 360 + 0.5 * M
m = M / 60 * 360
Ax = A * math.sin(math.radians(h))
Ay = A * math.cos(math.radians(h))
Bx = B * math.sin(math.radians(m))
By = B * math.cos(math.radians(m))
print(((Ax - Bx) ** 2 + (Ay - By) ** 2) ** 0.5)

Solution (Python):
import math

a, b, h, m = map(int, input().split())
total_min = h * 60 + m
h_rad = math.radians((total_min/720)*360)
m_rad = math.radians((m/60)*360)
anssquare = a**2 + b**2 - 2*a*b*math.cos(abs(h_rad - m_rad))
print(math.sqrt(anssquare))

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

t = 60 * h + m
theta = t * 11 / 360
ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(theta * np.pi))

print(ans)

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

sita = min(360-abs((30*H+30*(M/60) )-6*M),abs((30*H+30*(M/60) )-6*M))
D2 =A**2+B**2-2*A*B*math.cos(math.radians(sita)) 
print(D2**(1/2))

Solution (Python):
import math
a,b,h,m=map(int,input().split())
lo=360*((h*60+m)/720)
sh=360*(m/60)
si=min(abs(lo-sh),360-max(lo,sh)+min(lo,sh))
si1=math.radians(si)
print((a**2+b**2-2*a*b*math.cos(si1))**(1/2))

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

p=math.pi*m/30 - math.pi*(h+m/60)/6

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

Solution (Python):
import math

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

A_degree = H * 30 + 0.5 * M
B_degree = M * 6

AB = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(A_degree - B_degree)))
print(AB)

Solution (Python):
import math

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

ca = (2*math.pi/12 * (h + m/60)) % (2*math.pi)
cb = 2*math.pi * m/60

c = abs(ca - cb)
if c > math.pi:
    c = 2*math.pi - c

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

Solution (Python):
import math
import numpy as np

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

minit = M + H * 60
long_r = 360*minit/(60*12)
short_r = 6*M

Ax = A*math.cos(math.radians(long_r))
Ay = A*math.sin(math.radians(long_r))
Bx = B*math.cos(math.radians(short_r))
By = B*math.sin(math.radians(short_r))

d = np.sqrt((Ax-Bx)**2+(Ay-By)**2)
print(d)

Solution (Python):
import math

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

hh=360.0*h/12.0+30.0*m/60.0
mm=360.0*m/60.0

theta=abs(hh-mm)/180.0*math.pi

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

print(ans)

Solution (Python):
import math

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

c=math.radians(abs(30*(h+m/60)-6*m))

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

Solution (Python):
import collections
from collections import defaultdict
import math
import numpy as np
import re
import itertools
import bisect

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

l = 6*m
s = 0.5*m+30*h

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

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

h_rad = (H+M/60)/12 *2*math.pi
m_rad = M/60 * 2 * math.pi

h_x = A * math.sin(h_rad)
h_y = A * math.cos(h_rad)

m_x = B * math.sin(m_rad)
m_y = B * math.cos(m_rad)

print(math.sqrt(pow(h_x-m_x, 2) + pow(h_y-m_y, 2)))

Solution (Python):



import math

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

print(math.sqrt(A**2+B**2 -2*A*B*math.cos((30*H-11*M/2)/180*math.pi)))

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

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

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

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

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

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


cos_c = math.cos(math.radians(angle))

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

Solution (Python):
import math

a, b, h, m = map(int, input().split())
theta = math.pi  * h / 6 - math.pi * 11 * m / 360

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

Solution (Python):

import sys
from math import sin, cos, radians

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


A, B, H, M = lr()
d1 = radians((30 * H + 30 * M / 60) - 90)
d2 = radians((360 * M / 60) - 90)
x1, y1 = A * cos(d1), A * sin(d1)
x2, y2 = B * cos(d2), B * sin(d2)
dis = ((x1-x2) ** 2 + (y1-y2) ** 2) ** .5
print(dis)

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

Solution (Python):

import sys
import math


def solve(A: int, B: int, H: int, M: int):
    m = H * 60 + M
    a = 6 * m
    b = 0.5 * m

    print (math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(a - b))))
    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):
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial, cos, pi, degrees
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

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

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

aB = M/60
aA = (H+aB)/12

aB = aB * 2 * pi
aA = aA * 2 * pi

rad = abs(aB - aA)
if rad > pi:
    rad = 2*pi - rad

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

Solution (Python):
import math

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

br = 2 * math.pi * M/60
ar = 2 * math.pi * (60 * H + M)/720

C = math.sqrt(A**2 + B**2 -2*A*B*math.cos(br - ar))

print(C)

Solution (Python):
import math
a, b, h, m = [int(i) for i in input().split()]
h_rad = (h + m / 60) / 12
m_rad = m / 60
t = abs(h_rad - m_rad)
rad = min(t, 1-t) * 2 * math.pi
c2 = a*a + b*b - 2 * a * b * math.cos(rad)
print(math.sqrt(c2))

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

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

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

[xa, ya] = [a*cos(theta_a), a*sin(theta_a)]
[xb, yb] = [b*cos(theta_b), b*sin(theta_b)]

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

Solution (Python):
import math

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

a_x = a*math.cos(math.radians(30*h+0.5*m-90))
a_y = a*math.sin(math.radians(30*h+0.5*m-90))
b_x = b*math.cos(math.radians(6*m-90))
b_y = b*math.sin(math.radians(6*m-90))

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

Solution (Python):
import math
p=math.pi
a,b,h,m=map(int,input().split())
j=(b*math.cos(p*m/30),b*math.sin(p*m/30))
t=(a*math.cos((h/6+m/360)*p),a*math.sin((h/6+m/360)*p))
print(((j[0]-t[0])**2+(j[1]-t[1])**2)**(0.5))

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

import math
import numpy as np

t = H + M/60
w_A = 2 * math.pi / 12 * t
w_B = 2 * math.pi * t

x_A = A * math.cos(w_A)
y_A = A * math.sin(w_A)

x_B = B * math.cos(w_B)
y_B = B * math.sin(w_B)

xy_A = np.array([x_A, y_A])
xy_B = np.array([x_B, y_B])

u = xy_A - xy_B

print(np.linalg.norm(u))

Solution (Python):
a,b,h,m=map(int,input().split())
import math
toki=360*(h*60+m)/(12*60)
fun=360*m/60
aida=abs(fun-toki)
cos=math.cos(math.radians(aida))
nijou=a**2+b**2-(2*a*b*cos)
print(nijou**(1/2))

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

Solution (Python):
import math

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

jikan = (H/12 + M/(60 *12)) * 360
hun = (M/60) * 360

kakudo = jikan - hun

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

Solution (Python):
import math

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


h = h + m /60
h_sin = math.sin(math.radians(h/12*360))
h_cos = math.cos(math.radians(h/12*360))
m_sin = math.sin(math.radians(m/60*360))
m_cos = math.cos(math.radians(m/60*360))

ans = math.sqrt((h_sin*a-m_sin*b)**2+(h_cos*a-m_cos*b)**2)

print(ans)

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

a = 30 * H + 30 * (M / 60)
b = 360 * M /60

ans = A**2 + B**2 - 2 * A * B * math.cos((abs(a - b) * math.pi / 180))
ans = math.sqrt(ans)
print(ans)

Solution (Python):
import math


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

PI = math.pi

tan_deg = H / 12 * (2 * PI) + M / 60 * (PI / 6) 
chou_deg = M / 60 * (2 * PI)

kakudo = abs(chou_deg-tan_deg)

C2 = A**2 + B**2 - 2*A*B * math.cos(kakudo)

ans = math.sqrt(C2)


print(ans)

Solution (Python):
import math
A, B, H, M = map(int,input().split())
nagai = (60*H+M)/2
mijikai = 6*M
Nx= A*math.sin(math.radians(nagai))
Ny = A*math.cos(math.radians(nagai))
Sx= B*math.sin(math.radians(mijikai))
Sy= B*math.cos(math.radians(mijikai))

ans = ((Nx-Sx)**2+(Ny-Sy)**2)**0.5
print(ans)

Solution (Python):
a,b,h,m = map(int,input().split())
import math
xa = a*math.cos((60*h+m)*math.pi/360)
ya = a*math.sin((60*h+m)*math.pi/360)
xb = b*math.cos(m*math.pi/30)
yb = b*math.sin(m*math.pi/30)
print(((xa-xb)**2+(ya-yb)**2)**0.5)

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

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

short = pi * (h * 60 + m) / 360
long = pi * m / 30

print(sqrt(a*a + b*b - 2*a*b*cos(short - long)))

Solution (Python):
import numpy as np

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

h_ = (h+m/60) * 30
m_ = m * 6
kakudo = abs(h_-m_)
kakudo = min(360-kakudo, kakudo)

ans = (a**2 + b**2 - 2*a*b*np.cos(kakudo*np.pi/180))**0.5
print(ans)

Solution (Python):
import math

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

short_l = h*math.pi/6 + m*math.pi/360
long_r = m*math.pi/30

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(abs(short_l-long_r)))

print(ans)

Solution (Python):
import math

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

s = 60*h - 11*m
ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.pi*s/360))
print(ans)

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

Solution (Python):
import math


def solve(A, B, H, M):
    h = (360 / 12) * H + (360 / 12 / 60) * M
    m = (360 / 60) * M
    oa = (A * math.sin(math.radians(h)), A * math.cos(math.radians(h)))
    ob = (B * math.sin(math.radians(m)), B * math.cos(math.radians(m)))

    x = oa[0] - ob[0]
    y = oa[1] - ob[1]
    return (x ** 2 + y ** 2) ** 0.5


if __name__ == "__main__":
    A, B, H, M = tuple(map(int, input().split(" ")))
    print(solve(A, B, H, M))

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

Solution (Python):
import numpy as np
a,b,h,m=map(int,input().split())
l=m*6
s=h*30+m/2
dis=a**2+b**2-2*a*b*np.cos((l-s)/360*2*np.pi)
dis=np.sqrt(dis)
print(dis)

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

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

d = abs(H-M)
if d > 180:
    d = 360 - d



C = pow(A**2+B**2-2*A*B*math.cos(math.radians(d)),0.5)

print(C)

Solution (Python):
A,B,H,M=map(int,input().split())
import math
M=M+60*H
hd=M/2
md=6*(M%60)
x=max(hd,md)-min(hd,md)
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(x))))

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

import math

t = H * 60 + M

ax = A * math.sin(2 * math.pi * t / 720)
ay = A * math.cos(2 * math.pi * t / 720)

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




dx = ax - bx
dy = ay - by

print(math.sqrt(dx * dx + dy * dy))

Solution (Python):
import math

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

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

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

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

main()

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

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

kaku_min = 6*m
kaku_hr = 30*h+0.5*m
delta = abs(kaku_min - kaku_hr)
kaku = min(360-delta, delta)
c = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(np.pi*kaku/180))
print(c)

Solution (Python):
import numpy as np

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

ang1 = ((30*h+m/2)*np.pi)/180
ang2 = (6*m*np.pi)/180







x_dis = a*np.cos(ang1)-b*np.cos(ang2)
y_dis = a*np.sin(ang1)-b*np.sin(ang2)

dist = np.sqrt(x_dis*x_dis+y_dis*y_dis)
print(dist)

Solution (Python):

import math

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

deg_h = (h*60+m)/(12*60)*2*math.pi
deg_m = (m/60)*2*math.pi



h_x = a*math.sin(deg_h)
h_y = a*math.cos(deg_h)




m_x = b*math.sin(deg_m)
m_y = b*math.cos(deg_m)


ans = ((h_x-m_x)**2+(h_y-m_y)**2)**0.5
print(ans)

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

import math

zir=2*math.pi*(h/12+m/720)
hunr=2*math.pi*m/60

zixy=(a*math.cos(zir),a*math.sin(zir))
hunxy=(b*math.cos(hunr),b*math.sin(hunr))

print(math.sqrt((zixy[0]-hunxy[0])**2+(zixy[1]-hunxy[1])**2))

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

Solution (Python):
import math

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

ang = (H*30+M*0.5-M*6)/180*math.pi

l = math.sqrt(A**2+B**2-2*A*B*math.cos(ang))

print(l)

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

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

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

nakami = (60*H - 11*M)*pi/360
cs = math.cos(nakami)

anssq = A**2 + B**2 - 2*A*B*cs
ans = math.sqrt(anssq)
print(ans)

Solution (Python):

import sys
input = sys.stdin.readline



import math

def main():
    a, b, h, m = map(int, input().split())
    degh = (h*60 + m)/720. * 360
    degm = m/60. * 360
    cos = math.cos(math.radians(abs(degh - degm)))
    anssqure = a**2 + b**2 - 2*a*b*cos
    print(anssqure**0.5)
    


    
if __name__ == '__main__':
    main()

Solution (Python):
import math

pi = math.pi
a, b, h, m = map(int, input().split())
m_theta = m*2*pi/60
h_theta = h*2*pi/12 + m*2*pi/720
theta = abs(h_theta-m_theta)

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

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

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

Ax, Ay = cos(M / 30 * pi) * A, sin(M / 30 * pi) * A
Bx, By = cos((M + H * 60) / 360 * pi) * B, sin((M + H * 60) / 360 * pi) * B

print(((Ax - Bx) ** 2 + (Ay - By) ** 2) ** 0.5)

Solution (Python):
from math import radians,cos

a,b,h,m = map(int,input().split())
j = 30*h+(0.5)*m
f = 6*m
k = abs(j-f) if abs(j-f) <= 180 else 360-abs(j-f)
print((a**2+b**2-2*a*b*cos(radians(k)))**(0.5))

Solution (Python):
from math import pi, cos, sqrt
A, B, H, M = map(int, input().split())
t = H * 60 + M
deg = abs(t / 2 - (t % 60) * 6)
if deg > 180:
    deg = 360 - deg
deg = deg * pi / 180
print(sqrt(A*A + B*B - 2*A*B*cos(deg)))

Solution (Python):
import math

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

ancleA = 30 * h + 0.5 * m
ancleB = 6 * m

ancle = min(abs(ancleA - ancleB), 360 - abs(ancleA - ancleB))

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

Solution (Python):
import math


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

jikan = h * 30 + m * 0.5
hun = m * 6

kakudo = min(abs(jikan - hun), 360 - abs(jikan - hun))

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

Solution (Python):
import math
a,b,h,m=tuple(map(int,input().split()))
t=60*h+m
ka=min((t*5.5)%360,360-((t*5.5)%360))
c=a**2+b**2-2*a*b*math.cos(math.radians(ka))
l=math.sqrt(c)
print(l)

Solution (Python):
import math
a,b,h,m = map(int,input().split())
p = math.pi
r = h*p/6+m*p/360-m*p/30
cj = a**2 + b**2 - 2*a*b*math.cos(r)
print(math.sqrt(cj))

Solution (Python):
import math

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

h = (H*60 + M)/720*2*math.pi
m = M/60*2*math.pi

d = ((A*math.sin(h) - B*math.sin(m))**2 + 
     (A*math.cos(h) - B*math.cos(m))**2) **.5

print('{:.10f}'.format(d))