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):
from collections import Counter 
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)




ceil=lambda x,y: (x+y-1)//y
input_list = lambda : list(map(int,input().split()))


a,b,h,m=input_list()

a_thita=2*math.pi*(h/12+m/720)
b_thita=2*math.pi*(m/60)

a_xy=[(-1)*a*math.cos(a_thita-math.pi/2),(-1)*a*math.sin(a_thita-math.pi/2)]
b_xy=[(-1)*b*math.cos(b_thita-math.pi/2),(-1)*b*math.sin(b_thita-math.pi/2)]


ans=math.sqrt((a_xy[0]-b_xy[0])**2+(a_xy[1]-b_xy[1])**2)
print(ans)

Solution (Python):
from math import cos, pi
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 = [int(x) for x in input().strip().split()]

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

d = abs(a**2+b**2-2*a*b*cos(theta))
d = pow(d,1/2)
print(d)

Solution (Python):
import math as ma
a,b,h,m = map(int,input().split())
ans = abs(30 * (h%12) + 0.5 * m  - 6 * m)
if ans > 180:
    ans = abs(360 - ans)
c = ma.cos(ma.radians(ans))
res=(a**2)+(b**2)-((2*a*b)*c)
print(res**0.5)

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

dig_h = math.radians(360*h/12 + 30*m/60)
dig_m = math.radians(360*m/60)

x = b * math.sin(dig_h) - a * math.sin(dig_m)
y = b * math.cos(dig_h) - a * math.cos(dig_m)

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

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

kakudo_s = h * 30 + m / 2
kakudo_l = m * 6
import math
x_s = math.cos(math.radians(kakudo_s)) * a
y_s = math.sin(math.radians(kakudo_s)) * a
x_l = math.cos(math.radians(kakudo_l)) * b
y_l = math.sin(math.radians(kakudo_l)) * b

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

print(get_distance(x_s, y_s, x_l, y_l))

Solution (Python):
import math

A, B, H, M = map(int, input().split())
vh = (360 * H /12 )%360
vl = (360 * M /60 )%360
vh += (30 * M /60 )%30
X= abs(vh-vl)
print((A**2 +B**2 - 2 * A * B * math.cos(math.radians(X)))**0.5)

Solution (Python):
import math
A, B, H, M = map(int, input().split())
tyousin = M*360/60
tansin = (H*60+M)*360/(12*60)
deg = abs(tyousin-tansin)
if deg >= 180:
    deg = 360-deg

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

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

Solution (Python):
import math
a,b,h,m=map(int,input().split())
l=math.pow(a**2+b**2-2*a*b*math.cos(2*math.pi*((h+m/60)/12-m/60)),1/2)
print('{:.10f}'.format(l))

Solution (Python):
import sys, random, math
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
    inf = 10 ** 20



    t = 1
    
    for _ in range(1, t+1):
    
        
        a, b, h, m = map(int, input().split())
        
        a_a = ((h*60+m)/720) * 2 * math.pi
        b_a = (m / 60) * 2 * math.pi
        
        diff = abs(a_a - b_a)
        if(diff > math.pi):
            diff = 2*math.pi - diff
        
        ans = a*a+b*b-2*a*b*math.cos(diff)
        print(ans**0.5)
        
        
main()

Solution (Python):
import math
A, B, H, M = [int(i) for i in input().split()]
r1 = A
r2 = B
t1 = (H*60+M) / 720 * math.pi * 2
t2 = M / 60 * math.pi * 2
print((r1**2 + r2**2 - 2*r1*r2*math.cos(t1-t2))**(1/2))

Solution (Python):
a,b,h,m=map(int,input().split())
import numpy as np
theta = ((h+m/60)/12 - m/60)*2*np.pi
c=a**2+b**2-2*a*b*np.cos(theta)
print(np.sqrt(c))

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

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

minutes = h*60 + m

long_ = minutes / (12*60) * 360
short_ = (minutes % 60) / 60 * 360

theta = abs(long_ - short_)
import math
ans = b**2 + a**2 - 2*a*b*math.cos(math.radians(theta))


print(ans**(1/2))

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

h=(H*60+M)/2
m=6*M
import math

pi=math.pi
theta=abs(h-m)*2*pi/360


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

print(ans**0.5)

Solution (Python):
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

def main():
    a, b, h, m = map(int, input().split())
    hr = 30 * h + 0.5 * m
    mr = m * 6
    deg = abs(hr - mr)
    rad = math.radians(deg)
    cos = math.cos(rad)
    c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos)
    print(c)

if __name__ == '__main__':
    main()

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

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

theta1=30*H+M/2
theta2=6*M

d=A*A+B*B-2*A*B*math.cos(math.radians(theta1)-math.radians(theta2))
print(math.sqrt(d))

Solution (Python):
import math as m


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

angle_A = 30*H + 0.5*M
angle_B = 6*M
angle = abs(angle_A - angle_B)

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

Solution (Python):

import sys
import math
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(A: int, B: int, H: int, M: int):
    theta = math.radians(abs(360*(H*60+M)/(60*12)-360*M/60))
    print((A**2 - 2*A*B*math.cos(theta)+B**2)**0.5)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    H = int(next(tokens))  
    M = int(next(tokens))  
    solve(A, B, H, M)


if __name__ == '__main__':
    main()

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

a_kakudo=30*h+0.5*m
b_kakudo=6*m

diff=abs(a_kakudo-b_kakudo)



if diff>180:
    diff=360-diff
l=pow(a, 2)+pow(b, 2)-2*a*b*math.cos(math.radians(diff))
ans=pow(l, 0.5)
print(ans)

Solution (Python):
import sys
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    kakudo1 = M * 6
    kakudo2 = 30 * (H % 12) + M * 0.5

    x = min(abs(kakudo2 - kakudo1), abs(kakudo1 - kakudo2))

    x = min(x, abs(x - 360))


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


if __name__ == '__main__':
    main()

Solution (Python):

import sys
import math


def solve(A: int, B: int, H: int, M: int):
    x = abs((H*60+M)/2 - 6*M)
    ans = (A**2 + B**2 - 2*A*B*math.cos(math.radians(x))) ** 0.5
    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    H = int(next(tokens))  
    M = int(next(tokens))  
    solve(A, B, H, M)

if __name__ == '__main__':
    main()

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

Solution (Python):
import numpy as np

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

hangle = (H * 60 + M) / (12 * 60) * (2 * np.pi)
mangle = M / 60 * (2 * np.pi)

print(np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(np.abs(hangle - mangle))))

Solution (Python):
import math

a,b,h,m = map(int,input().split())
xhr = a*math.sin(((h+(m/60))/12)*(2*math.pi))
yhr = a*math.cos(((h+(m/60))/12)*(2*math.pi))
xmin = b*math.sin((m/60)*(2*math.pi))
ymin = b*math.cos((m/60)*(2*math.pi))
print(math.dist([xhr,yhr],[xmin,ymin]))

Solution (Python):
import math
a,b,h,m = map(int, input().split())
time = h * 60 + m
p = 2 *math.pi
lk = p * m / 60
sk = p * (h * 60 + m) /720
rad = max(lk,sk) - min(lk,sk)
if rad > math.pi:
    rad = p - rad
ans = (a**2) + (b**2) - 2*a*b*math.cos(rad)
print(ans**0.5)

Solution (Python):
import numpy as np
[a,b,h,m] = list(map(int, input().split()))
minute = h*60 + m
corrMin = minute % 60
minPointAngle = corrMin/60 * 360
hour = h + m/60
corrHour = hour % 12
hourPointAngle = corrHour/12 * 360
angleDiff = abs(hourPointAngle - minPointAngle)
length = np.sqrt(a**2 + b**2 - 2*a*b*np.cos(2*np.pi*angleDiff/360))
print(length)

Solution (Python):
import math
PI = math.pi
a, b, h, m = [int(x) for x in input().split()]
min = PI * m / 30
hr = PI * (60 * h + m) / 360
gamma = hr - min
ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(gamma))
print(ans)

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((h * 60 + m) * 5.5))))

Solution (Python):
import sys
import numpy as np
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    A, B, H, M = map(int, readline().split())
    long = 30*(H%12+M/60)
    short = 6*M
    ans = np.sqrt(A**2 + B**2 - 2*A*B*np.cos(np.deg2rad(long-short)))
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import math

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

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

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

Solution (Python):
def inp():exec('global inppp\ninpmoto,inppp=input().split(),[]\nfor i in inpmoto:\n try:inppp.append(int(i))if float(i).is_integer()else inppp.append(float(i));\n except:\n  try:inppp.append(str(i))\n  except:print("error in inp")');return inppp[0]if len(inppp)==1else list(inppp)
a, b, h, m = inp()
"""
時間は a cm
分は   b cm
"""
import math
kakudo_a = (60*h+m) / (12 * 60) * 360
kakudo_b = ((60*h+m) / 60 * 360) % 360
kakudo = (abs(kakudo_a - kakudo_b)/180) * math.pi
c = a ** 2 + b ** 2 - 2*a*b*math.cos(kakudo)
print(math.sqrt(c))

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

from math import cos, pi

t = abs((H + M / 60)/ 12 - M / 60) * 2 * pi

c = A**2 + B**2 - 2 * A * B * cos(t)

print(c**(1/2))

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    
    a,b,h,m = map(int,input().strip().split())
    theta = abs(m * Fraction(1,60) * 2 * math.pi) - (2*math.pi * (Fraction(h,12)+Fraction(m,720)))
    c=math.sqrt(a**2 + b**2 - 2*a*b*math.cos(theta))
    print(c)


if __name__ == '__main__':
    main()

Solution (Python):
from math import *

if __name__ == '__main__':
    s = input().rstrip().split(' ')
    A, B, H, M = int(s[0]), int(s[1]), int(s[2]), int(s[3])
    theta = abs(2*pi*(M/60.0) - (2*pi*(H/12.0)+(pi/6.0)*(M/60.0)))
    print(sqrt(A**2 + B**2 - 2*A*B*cos(theta)))

Solution (Python):
import sys


from math import sqrt, sin, cos, pi
from collections import defaultdict as dd, deque, Counter as C








mod = pow(10, 9) + 7
mod2 = 998244353


def data(): return sys.stdin.readline().strip()


def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)


def l(): return list(sp())


def sl(): return list(ssp())


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


def calcAngle():
    global 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)
    return min(360 - angle, angle)


a, b, h, m = sp()
temp = calcAngle()
temp = (pi * temp) / 180
answer = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(temp))
out(answer)

Solution (Python):
import sys
import numpy as np





read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    a, b, h, m = list(map(int, input().split()))
    rad = abs(6*m-(h*60+m)/2)
    print(np.sqrt(a**2+b**2-2*a*b*np.cos(rad/180*np.pi)))


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
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()

h_rad = 360 * H / 12 + M / 60 * 360 / 12
m_rad = 360 * M / 60

h = radians(h_rad)
m = radians(m_rad)
c = A ** 2 + B ** 2 - 2 * B * A * cos(h - m)  
print(sqrt(c))

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")











A,B,H,M = map(int,input().split())
hun = H * 60 + M
kaku = 5.5*hun
kaku = kaku % 360
rad = math.radians(kaku)
c = A**2+B**2-2*A*B*math.cos(rad)
d = c ** (0.5)
print(d)

Solution (Python):
from sys import stdin, setrecursionlimit
from math import radians, cos


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

    d_h = 360 * (h + m / 60) / 12
    d_m = 360 * m / 60

    d = abs(radians(d_h - d_m))

    print((a ** 2 + b ** 2 - 2 * a * b * cos(d)) ** 0.5)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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


a,b,h,m=map(int,input().split())
t=60*h+m
hun=6*t%360
zi=0.5*t
deg=min(360-abs(zi-hun),abs(zi-hun))
ans=a**2+b**2-2*a*b*math.cos(math.radians(deg))
print(pow(ans,0.5))

Solution (Python):
import math
a,b,h,m=map(int, input().split())
rad1 = m*5.5
rad2 = h*(360/12)
res = a**2 + b**2 - 2*a*b*math.cos(math.radians(abs(rad1 - rad2)))
print(math.sqrt(res))

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import cos, sqrt, radians
def solve():
    a, b ,h, m = MI()

    tyou = 0
    tan = 0
    for i in range(12):
        for j in range(60):
            
            if i == h and j == m:
                theta = abs(tan - tyou)
                theta = min(theta, 360 - theta)
                
                
                ans = sqrt(a**2 + b**2 - 2*a*b*cos(radians(theta)))
                print(ans)
                return
            tan += 0.5
            tyou += 6
        tyou = 0

if __name__ == '__main__':
    solve()

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

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left
from heapq import *
import sys

INF = 10 ** 17
MOD = 998244353

def check(mid, points, origin, rotate):
    height = origin * math.cos(math.radians(rotate))
    
    cs = math.cos(math.radians(rotate))
    sn = math.sin(math.radians(rotate))
    for px, py in points:
        py = py - origin
        rx, ry = px*cs - py * sn, px * sn + py * cs
        if abs(rx) > height + 0.0000001 or abs(ry) > height + 0.0000001:
            
            return False

    return True


class Segtree_op():
    def __init__(self, n):
        self.size = 1
        while (n >= 1):
            self.size = self.size << 1
            n = n // 2

        self.arr = [self.unit() for i in range(self.size * 2)]

    def op(self, lch, rch):
        return lch + rch

    def unit(self):
        return 0

    def update(self, k, val):
        k += self.size - 1
        self.arr[k] = val
        while (k):
            k = (k - 1) // 2
            self.arr[k] = self.op(self.arr[k * 2 + 1], self.arr[k * 2 + 2])

    def query(self, l, r):
        L = l + self.size
        R = r + self.size
        s = self.unit()
        while L < R:
            if R & 1:
                R -= 1
                s = self.op(s, self.arr[R - 1])

            if L & 1:
                s = self.op(s, self.arr[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return s

    def show(self):
        idx = 1
        while (idx <= self.size):
            print(self.arr[idx - 1:idx * 2 - 1])
            idx *= 2


def solve():
    a, b, h, m = getList()
    mdeg = 360 * (m / 60)
    hdeg = 360 * ((60 * h + m) / 720)
    hx, hy = a * math.cos(math.radians(hdeg)), a * math.sin(math.radians(hdeg))
    mx, my = b * math.cos(math.radians(mdeg)), b * math.sin(math.radians(mdeg))
    print(math.sqrt((hx - mx) ** 2 + (hy - my) ** 2))
    

def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    solve()

Solution (Python):
import math

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

h = H / 12 * 360 + M / 2
m = M / 60 * 360

d = min(360 - abs(h-m), abs(h-m))
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(d)))

print(C)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

""" Input
S = input().rstrip()
N = int(input())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np

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

l_pos = 6 * M
s_pos = 30 * H + 0.5 * M

deg = s_pos - l_pos

sa = np.sqrt(A ** 2 + B ** 2 - 2 * A * B * np.cos(np.deg2rad(deg)))
print(sa)

Solution (Python):
import math

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

    hun = m / 60
    zi = (h * 60 + m) / (60 * 12)

    theta = abs(hun - zi)
    
    C = math.cos(min(theta, 1 - theta) * 2 * math.pi)
    ans = math.sqrt(a * a + b * b - 2 * a * b * C)
    print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split(" "))
c=h*30+m/2
d=m*6

if c-d>180:
  e=d+(360-c)
  ans=math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(e)))
elif c-d==180:
  ans=a+b
else:
  e=c-d
  ans=math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(e)))
print(ans)

Solution (Python):
def main():
    import math
    a,b,h,m = map(int,input().split())
    mang = m*6
    hang = h*30+m*0.5
    arg = abs(hang-mang)
    arg = min(360-arg,arg)
    l = a**2+b**2-2*a*b*math.cos(arg/180*math.pi)
    print(l**0.5)

if __name__ == "__main__":
    main()

Solution (Python):
import math

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

angle = 30*H + M*0.5 - M*6
rad = math.radians(angle)
print( (A*A + B*B - 2*A*B*math.cos(rad)) **0.5 )

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

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

f = lambda a, b, c: math.sqrt(a ** 2 + b ** 2 -2 * a * b * math.cos(math.radians(c)))

print(f(A, B, min(abs(a - b), 360 - abs(a - b))))

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    A,B,H,M = LI()

    ta = (H / 12 + M / 60 / 12) * 2 * math.pi
    tb = M / 60 * 2 * math.pi
    xa = A * math.sin(ta)
    ya = A * math.cos(ta)
    xb = B * math.sin(tb)
    yb = B * math.cos(tb)
    d = math.sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb))
    print(d)

if __name__ == '__main__':
    main()

Solution (Python):
from math import cos, sqrt, pi
a, b, h, m = [int(i) for i in input().split()]
mdeg = 6 * m
hdeg = 30 * (h + m/60)

deg = abs(hdeg - mdeg)
if deg >= 180:
    deg = 360 - deg

print( sqrt(a ** 2 + b ** 2 - 2*a*b*cos(deg/180 *  pi)))

Solution (Python):
import math

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

total_minute = H*60 + M
angleH = 2 * math.pi * total_minute / (12*60)
angleM = 2 * math.pi * M / (60)

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

Solution (Python):
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    import math
    a,b,h,m=L()
    m_rote=360//60*m
    h_rote=360/(12*60)*(h*60+m)
    rot=abs(m_rote-h_rote)
    ans=pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(rot))
    print(pow(ans,1/2))
    

if __name__ == '__main__':
    main()

Solution (Python):
from math import pi,cos,sqrt
a,b,h,m=map(int,input().split())
th1=(h/6+m/360)*pi
th2=m*pi/30
th=abs(th1-th2)
th=min(th,360-th)
print(sqrt(a**2+b**2-2*a*b*cos(th)))

Solution (Python):
import math

A, B, H, M = [int(x) for x in input().split()]
angle = abs(M/60 - (H * 60 + M)/720) * 2 * math.pi
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle))
print(ans)

Solution (Python):
import math

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


kakuA = 2*math.pi*(H*60+M) / (12*60)
kakuB = 2*math.pi*M / 60
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(abs(kakuA-kakuB))))

Solution (Python):
import math
import numpy as np

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

h_direct = 30*h+m/2
m_direct = 6*m


ax = a*math.sin(math.radians(h_direct))
ay = a*math.cos(math.radians(h_direct))
bx = b*math.sin(math.radians(m_direct))
by = b*math.cos(math.radians(m_direct))


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

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

theta_a = (60*h+m)/720 * 360
theta_b = m/60 * 360

p1 = (a*cos(radians(theta_a)) - b*cos(radians(theta_b))) **2
p2 = (a*sin(radians(theta_a)) - b*sin(radians(theta_b))) **2

print(sqrt(p1+p2))

Solution (Python):
import math

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

    radianM=6*M
    radianH=30*H+(0.5*M)

    theta=math.radians(abs(radianM-radianH))

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

    print(C)

if __name__=="__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
import math


def main():
    A, B, H, M = map(int, input().split())
    theta = abs(6 * M - 30 * (H + M / 60))
    c = (B ** 2 + A ** 2 - 2 * A * B * math.cos(math.radians(theta))) ** 0.5
    print(c)

if __name__ == '__main__':
    main()

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

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

minutes = h * 60 + m

short_angle = pi * minutes / 360
long_angle = pi * m / 30
angle = abs(short_angle - long_angle)
if angle > pi:
    angle = 2 * pi - angle

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

Solution (Python):
import math
A,B,H,M = map(int,input().split())
t = ((11*M)/360 -H/6)*(math.pi)
p = A**2 + B**2 - 2*A*B*math.cos(t)
print(p**(1/2))

Solution (Python):
from math import *

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

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

print((a**2+b**2-2*a*b*cos(deg/180*3.141592653589793238462))**0.5)

Solution (Python):

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

h = 30
h_m = 1/2
m = 6

x = A**2 + B**2 - 2*A*B*math.cos(math.radians(H*h+M*h_m-M*m))
print(math.sqrt(x))

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

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

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

ax = a * math.cos(math.radians(h*30 + m/2))
ay = a * math.sin(math.radians(h*30 + m/2))
bx = b * math.cos(math.radians(6*m))
by = b * math.sin(math.radians(6*m))
print(math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by)))

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

Solution (Python):
import math
a, b, h, m = list(map(int, input().split()))
ar = 360 * ((h * 60 + m) / 720)
br = 360 * (m / 60)
r = min(abs(ar - br), 360 - abs(ar - br))
t = math.radians(r)
ans = a * a + b * b - 2 * a * b * math.cos(t)
ans = ans ** (1/2)
print(ans)

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

Solution (Python):
a,b,h,m = map(int, input().split())
import math
c = 30*h+0.5*m
d = 6*m
e = min(360-abs(c-d),abs(c-d))
a2 = a*a
b2 = b*b
c2 = 2*a*b*math.cos(math.radians(e))
ans = math.sqrt(a2+b2-c2)
print(ans)

Solution (Python):

import numpy as np
import math

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

ax = a * math.cos(math.pi / 6 * h + math.pi / 360 * m)
ay = a * math.sin(math.pi / 6 * h + math.pi / 360 * m)

bx = b * math.cos(math.pi / 30 * m)
by = b * math.sin(math.pi / 30 * m)

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

print(ans)

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

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

    h = H*30 + M*0.5
    ay = math.sin(math.radians(h)) * A
    ax = math.cos(math.radians(h)) * A

    bx = math.cos(math.radians(M*6)) * B
    by = math.sin(math.radians(M*6)) * B

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


if __name__ == "__main__":
    main()

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

import math

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

C = math.cos(math.radians(abs(h-m)))

c = math.sqrt(A*A + B*B - 2*A*B*C)

print(c)

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

x=30*h+0.5*m
y=6*m
k=min(abs(x-y),360-abs(x-y))

print((a**2+b**2-2*a*b*math.cos(k*2*math.pi/360))**(1/2))

Solution (Python):
A,B,H,M = [int(x) for x in input().split()]
import math
radian = math.radians(30*H - M*11/2)
ans = (A**2 + B**2 - 2 * A * B * math.cos(radian))**(1/2)
print(ans)

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")



def main():
    A, B, H, M = map(int, input().split())
    
    theta_a = math.radians(360) * (H / 12 + M / (12 * 60))
    theta_b = math.radians(360) * (M / 60)

    theta = abs(theta_a - theta_b)
    theta = min(theta, 2 * math.pi - theta)
    C = math.sqrt(A * A + B * B - (2 * A * B * math.cos(theta)))
    print(C)


if __name__ == '__main__':
    main()

Solution (Python):
import math


A, B, H, M = map(int, input().split())
b = 360 * M / 60
a = (H * 60 + M) * 360 / (12 * 60)
print((A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(b - a))) ** .5)

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


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


p = np.pi
h_m = h * 60 + m

arg_min = 2 * p / 60 * m
arg_hor = 2 * p / 720 * h_m

the = float(abs(arg_min-arg_hor))

ans = np.sqrt(a**2 + b**2 - 2 *a*b*np.cos(the))

print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
d=30*h-5.5*m

if d>180:
  d=360-d
d=d*math.pi/180

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

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

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

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

kakudo = abs(m - h)
if kakudo > math.pi:
    kakudo = 2 * math.pi - kakudo

s = A ** 2 + B ** 2 - (2 * A * B) * math.cos(kakudo)
print(math.sqrt(s))

Solution (Python):
import math
A, B, H, M = map(int,input().split())
h = (60 * H + M) * 0.5
m = (60 * H + M) * 6
cosC = math.cos(math.radians(h - m))
ans = (A ** 2 + B ** 2 - 2 * A * B * cosC) ** 0.5
print(ans)

Solution (Python):
import math
a,b,h,m=map(int,input().split())
sa=h*30+m/2
sb=6*m
s=max(sa,sb)-min(sa,sb)
if s>180:
  s=360-s
cos=math.cos(math.radians(s))
ans=(a**2+b**2-2*a*b*cos)**(1/2)
print(ans)

Solution (Python):
import numpy as np

A,B,H,M=list(map(int,input().split()))
x=2*np.pi*(H*60+M)/(12*60)
y=M*2*np.pi/60
print(np.sqrt(A**2+B**2-2*A*B*np.cos(np.abs(x-y))))