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())
H = 60*H + M
pi = (math.pi/180)
HP = [A*math.cos(0.5*H*pi), A*math.sin(0.5*H*pi)]
MP = [B*math.cos(6*M*pi), B*math.sin(6*M*pi)]

print(math.sqrt((HP[0]-MP[0])**2 + (HP[1]-MP[1])**2))

Solution (Python):
A,B,H,M=map(float,input().split())
import math
rad_min =2.0*math.pi*M/60
rad_hour = 2.0*math.pi*H/12.0+math.pi/6.0*M/60.0
rad=abs(rad_min-rad_hour)
l=math.sqrt(A**2+B**2-2.0*A*B*math.cos(rad))
print(l)

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


hour_theta= np.pi*(60*h+m)/360
minute_theta=np.pi*m/30

theta = abs(hour_theta-minute_theta)




ans=np.sqrt((a**2)+(b**2)-2*a*b*np.cos(theta))
print('{:.11f}'.format(ans))

Solution (Python):
import math
a,b,h,m=map(int,input().split())
lrad=6*m
srad=30*h+0.5*m
if abs(lrad-srad)<=180:
    do=abs(lrad-srad)
else:
    do=360-abs(lrad-srad)
rad=math.radians(do)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(rad)))

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






import sys

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

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

A, B, H, M = na()
l = 360 / 12 * (H + M / 60)
s = 360 / 60 * M
print(math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(abs(l - s) * math.pi / 180)))

Solution (Python):
import math

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

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

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

Solution (Python):
import math
pi=math.pi
a,b,h,m=map(int,input().split())
ra=((60*h+m)/360)*180
rb=(180/30)*m
r=abs(ra-rb)
if r>2*180:
    r=2*180-r
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(r*2*pi/360))
print(f'{ans:.20f}')

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

f=h / 12 * 360 - m / 60 * 360 + m / 60 / 12 * 360

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

Solution (Python):
import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf, pi, cos
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

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

tmp = 0
res = 0

theta = 2 * pi * (h / 12.0 + m / 720.0 - m / 60.0)
res = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(theta))

print(res)

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

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

c=abs(30*h-11/2*m)
ct=math.radians(c)
cos=math.cos(ct)
ans=a**2+b**2-2*a*b*cos
print(math.sqrt(ans))

Solution (Python):
import math
 
A, B, H, M = map(int, input().split())
 
angle_A = 6*M
angle_B = 30*(H+M/60)
angle_C = abs(angle_A-angle_B)
 
rad_C = math.radians(angle_C)
 
C = math.sqrt(A**2+B**2-2*A*B*math.cos(rad_C))
 
print(C)

Solution (Python):
import math

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

angle_A = 6*M
angle_B = 30*(H+M/60)
angle_C = abs(angle_A-angle_B)

rad_C = math.radians(angle_C)

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

print(C)

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

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

Solution (Python):
def main(sample_file = ''):

    """ convenient functions
    
    
    
    
    
    """

    """convenient decorator
    
    
        
        
        
        
        
        
        
        
        
        
    """
    
    
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product, combinations_with_replacement 
    
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  
        b, e = 2, 0  
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):   
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict 
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
    from copy import deepcopy, copy 
    import operator
    
    from operator import itemgetter 
    
    
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd
    def gcd(a,b):
        
        
        if a<b:
            a, b = b, a
        while a%b !=0 :
            a, b = b, a%b
        return b

    
    
    
    
    
    

    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)
    def make_divisors(n, reversed=False):
        """create list of divisors
        
        Args:
            number (int): number from which list of divisors is created
            reversed (bool, optional): ascending order if False. Defaults to False.
        
        Returns:
            list: list of divisors
        """
        divisors = set()
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.add(i)
                divisors.add(n//i)
        return sorted(list(divisors),reverse=reversed)

    
    def sieve_of_eratosthenes(end, typecode="L"):
        
        

        
        import array
        import textwrap
        assert end > 1
        
        
        
        is_prime = array.array("B", (True for i in range(end)))
        
        is_prime[0] = False
        is_prime[1] = False
        
        primes = array.array(typecode)
        
        for i in range(2, end):
            if is_prime[i]:
                primes.append(i)
                for j in range(2 * i, end, i):
                    is_prime[j] = False  
        return primes

    class PrimeFactorization:
        '''初期化にO(NloglogN)/ 因数分解クエリをO(log(k))/ 素数判定クエリをO(1)
        >>> pf = PrimeFactorization(100)
        >>> pf.query(100)
        ((2, 2), (5, 2))
        
        '''
        
        
        
        
        
        
        
        def __init__(self, Num=10**6):
            from collections import defaultdict
            from math import floor
            self.Num = Num
            self.D = [-1] * (Num+1)
            for i in range(2, Num+1):
                if self.D[i] != -1:
                    continue
                self.D[i] = i
                for j in range(1, floor(Num/i)+1):
                    if self.D[j*i] != -1:
                        continue
                    else:
                        self.D[j*i] = i
        
        def query(self, k):
            ans = defaultdict(int)
            tmp = k
            while self.D[tmp] != -1:
                div = self.D[tmp]
                ans[div] += 1
                tmp = tmp//div
            return tuple(ans.items())
        
        def is_prime(self, k):
            return k == self.D[k]

    
    
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    AtoZ = list('abcdefghijklmnopqrstuvwxyz') 
    modpow = lambda a, n, p = MOD: pow(a, n, p) 
    def modinv(a, p = MOD):
        
        
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        
        
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    class UnionFindTree:
        """union find tree class
        TODO: fix this description...
        how to use (example):
        >>  uf = UnionFindTree(N) 
        >>  if uf.find_root(a) == uf.find_root(b):
        >>      do something like:
        >>      pass
        >>  else:
        >>      do something like:
        >>      L[find_root(a)] = L[find_root(a)] + L[find_root(b)]
        >>      L[find_root(b)] = L[find_root(a)]
        >>      
        >>      uf.unite(a, b)
        """
        def __init__(self, N):
            self.root = [-1] * (N+1)
            self.rank   = [0]  * (N+1)
            self.connected_num = [1] * (N+1)
    
        def find_root(self,x):
            root = self.root
            while root[x] != -1:
                x = root[x]
            return x
    
        def unite(self,x,y):
            root = self.root
            rank = self.rank
            connected_num = self.connected_num
            find_root = self.find_root
    
            rx = find_root(x)
            ry = find_root(y)
            if rx != ry:
                if rank[rx] < rank[ry]:
                    root[rx] = ry
                    rx,ry = ry,rx
                else:
                    if rank[rx] == rank[ry]:
                        rank[rx] += 1
                    root[ry] = rx       
                connected_num[rx] += connected_num[ry]

    
    
    
    class SegTree:
        """
        ref: https://qiita.com/takayg1/items/c811bd07c21923d7ec69
        init(init_val, ide_ele): 配列init_valで初期化 O(N)
        update(k, x): k番目の値をxに更新 O(logN)
        query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
        
        操作	    segfunc	        単位元
        最小値	    min(x, y)	    float('inf')
        最大値	    max(x, y)	    -float('inf')
        区間和	    x + y	        0
        区間積	    x * y	        1
        最大公約数	math.gcd(x, y)	0
        
        ex: seg = SegTree([14, 5, 9, 13], min, float('inf'))
        """
        def __init__(self, init_val, segfunc, ide_ele):
            """
            init_val: 配列の初期値
            segfunc: 区間にしたい操作
            ide_ele: 単位元
            n: 要素数
            num: n以上の最小の2のべき乗
            tree: セグメント木(1-index)
            """
            n = len(init_val)
            self.segfunc = segfunc
            self.ide_ele = ide_ele
            self.num = 1 << (n - 1).bit_length()
            self.tree = [ide_ele] * 2 * self.num
            
            for i in range(n):
                self.tree[self.num + i] = init_val[i]
            
            for i in range(self.num - 1, 0, -1):
                self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

        def update(self, k, x):
            """
            k番目の値をxに更新
            k: index(0-index)
            x: update value
            """
            k += self.num
            self.tree[k] = x
            while k > 1:
                self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
                k >>= 1

        def query(self, l, r):
            """
            [l, r)のsegfuncしたものを得る
            l: index(0-index)
            r: index(0-index)
            """
            res = self.ide_ele
            l += self.num
            r += self.num
            while l < r:
                if l & 1:
                    res = self.segfunc(res, self.tree[l])
                    l += 1
                if r & 1:
                    res = self.segfunc(res, self.tree[r - 1])
                l >>= 1
                r >>= 1
            return res

    
    
    
    
    
    
    
    

    def BellmanFord(N, M, ABC, vertex_start, vertex_end, value_if_inf = -1, find_shortest = False):
        """to calculate furthest or shortest length between vertex_start and vertex_end using BellmanFord algorithm
        
        Args:
            N (int): number of vertices
            M (int): number of edges
            ABC (list): [(ai, bi, ci) for _ in range(N)] where i-th edge is directed from vertex ai to vertex bi and the length is ci 
            vertex_start (int): start vertex. usually use 0.
            vertex_end (int): end vertex. usually use N-1.
            value_if_inf (int or string as you like, optional): value you want when the furthest (or shortest) distance is infinite (or -infinite). Defaults to -1.
            find_shortest (bool, optional): choose False to find furthest path. Defaults to False.
        
        Returns:
            int or string: normally int (but can be str if you set value_if_inf to str)
            
        Example:
                N, M, P = R()
                ABC = [R() for _ in range(M)]
                ABC = [(a-1, b-1, c-P) for a, b, c in ABC]
                print(BellmanFord(N, M, ABC, 0, N-1, value_if_inf = 'inf'))

        """

        def make_reachable_list(N, M, ABC, vertex_start, vertex_end):
            reachable_to_direct = defaultdict(list)
            reachable_from_direct = defaultdict(list)
            reachable_from_start = [False] * N
            reachable_to_end = [False] * N
            reachable_from_start[vertex_start] = True
            reachable_to_end[vertex_end] = True
            reachable_from_both_sides = [False] * N
            dfs_from_start = []
            dfs_to_end = []
            for a, b, c in ABC:
                reachable_to_direct[a].append(b)
                reachable_from_direct[b].append(a)
                if a == vertex_start:
                    dfs_from_start.append(b)
                    reachable_from_start[b] = True
                if b == vertex_end:
                    dfs_to_end.append(a)
                    reachable_to_end[a] = True
            while dfs_from_start:
                v = dfs_from_start.pop()
                for i in reachable_to_direct[v]:
                    if not reachable_from_start[i]:
                        reachable_from_start[i] = True
                        dfs_from_start.append(i)
            while dfs_to_end:
                v = dfs_to_end.pop()
                for i in reachable_from_direct[v]:
                    if not reachable_to_end[i]:
                        reachable_to_end[i] = True
                        dfs_to_end.append(i)
            for i in range(N):
                reachable_from_both_sides[i] = reachable_from_start[i] and reachable_to_end[i]
            return reachable_from_both_sides
        
        reachable_from_both_sides = make_reachable_list(N, M, ABC, vertex_start, vertex_end)
        
        if find_shortest:
            dist = [INF for i in range(N)]
        else:
            dist = [-INF for i in range(N)]
        
        dist[vertex_start] = 0
        for i in range(N):
            updated = False
            for a, b, c in ABC:
                if not reachable_from_both_sides[a]:
                    continue
                elif find_shortest:
                    update_condition = dist[a] + c < dist[b]
                else:
                    update_condition = dist[a] + c > dist[b]
                if dist[a] != INF and update_condition:
                    dist[b] = dist[a] + c
                    updated = True
                    if i == N-1:
                        return value_if_inf
            if not updated:
                break
        return dist[vertex_end]

    
    def warshall_floyd(number_vertex, XYD, shift_one_for_vertex=False):
        
        
        
        
        
        d = [[float("inf")]*number_vertex for i in range(number_vertex)]
        for x, y, dist in XYD:
            if shift_one_for_vertex:
                x = x - 1
                y = y - 1
            d[x][y] = dist
            d[y][x] = dist
        for i in range(number_vertex):
            d[i][i] = 0 
        for k in range(number_vertex):
            for i in range(number_vertex):
                for j in range(number_vertex):
                    d[i][j] = min(d[i][j],d[i][k] + d[k][j])
        return d


    """ initialize variables and set inputs
    
        
        
            
            
    
        
        
        
        
        
        
        
    
        
        
        
        
    
        
        
    """

    
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    r_float = lambda: float(r())
    R = lambda: list(map(int, r().split()))
    
    R_map = lambda: map(int, r().split())
    R_float = lambda: list(map(float, r().split()))
    R_tuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    
    
    
    
    
    
    
    """

    
    if sample_file:
        sys.stdin = open(sample_file)
    
    
    import random
    
    
    
    
    import math
    A, B, H, M = R()
    u = H * 60 + M
    Jis = 0.5 * u
    Bun = 6 * u
    Dif = abs(Bun%360 - Jis%360)
    a = (A**2 + B**2 - 2*A*B*math.cos(math.radians(Dif)))**(0.5)
    print(a)
    
    
    

    """memo: how to use defaultdict of list
    
    Dic = defaultdict(list)
    
    Dic[x].append(y)
    
    for k, v in Dic.items():
    """
    
    """memo: how to solve binary problems
    https://atcoder.jp/contests/abc173/submissions/14966961
    for i in range(1<<h):
	    if (i >> x) & 1:
            hoge
    (1 >> x) & 1 でNビット目のビット値を取得している
    """
    
    """memo: how to solve the problem
    creating simple test/answer
    greed
    simple dp
    graph
    """

if __name__ == '__main__':
    main()

Solution (Python):
import math

lh, lm, h, m = (int(i) for i in input().split())
ang1 = 360 / 12 * h + (30 / 60) * m
ang2 = 360 / 60 * m
ang = abs(ang1 - ang2)

ang = ang / 360 * 2 * math.pi

sq = lh**2 + lm**2 - 2 * lh * lm * math.cos(ang)
print(math.sqrt(sq))

Solution (Python):
import math

A, B, H, M = map(int,input().split())
A_d = math.radians(30 * H + 0.5 * M)
B_d = math.radians(M * 6)

A_g = (math.cos(A_d) * A, math.sin(A_d) * A)
B_g = (math.cos(B_d) * B, math.sin(B_d) * B)

D = ((A_g[0] - B_g[0]) ** 2 + (A_g[1] - B_g[1]) ** 2) ** 0.5

print(D)

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

Solution (Python):
import math

a, b, h, m = map(int, input().split())
h_rad = (h * 60 + m) * math.pi / 360
m_rad = m * math.pi / 30
cosine = math.cos(abs(h_rad - m_rad))

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

Solution (Python):
import math

a, b, h, m = map(int, input().split())
angle = ((h * 60 + m) / 720 - m / 60) * math.pi * 2  
ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(angle))  
print(ans)

Solution (Python):
import numpy as np

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


angle_h = 1./ 12.*(H + M/60.) * 2*np.pi

angle_m = M/60. * 2 * np.pi

hour = (A*np.sin(angle_h), A*np.cos(angle_h))
minute = (B*np.sin(angle_m), B*np.cos(angle_m))

dist = np.sqrt((hour[0] - minute[0])**2 + (hour[1] - minute[1])**2)

print(dist)

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

m = 360/60 * M
h = 360/12 * (H + M/60)
deg = abs(h-m)
if deg>180: deg = 360-deg

import math

Csq = A**2 + B**2 - 2*A*B*math.cos(math.radians(deg))
print('{:.10f}'.format(math.sqrt(Csq)))

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

theta = abs(h/12-11*m/720)*2*np.pi
print(np.sqrt((a*a+b*b-2*a*b*np.cos(theta))))

Solution (Python):
from math import *
def calcAngle(h,m):
         
        
        if (h < 0 or m < 0 or h > 12 or m > 60):
            print('Wrong input')
         
        if (h == 12):
            h = 0
        if (m == 60):
            m = 0
            h += 1;
            if(h>12):
                   h = h-12;
         
        
        
        
        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(i) for i in input().split()]
theta=calcAngle(h,m)*pi/180
ans=(a**2+b**2-2*a*b*cos(theta))**(1/2)
print("{:.15f}".format(ans))

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



theta = abs(((0.5 * (H * 60 + M)) - (6 * M)) % 360)
if theta > 180:
  theta = 360 - theta

import math
C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta / 180 * math.pi))
print(C)

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

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

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


r_a = 30*h + 0.5 * m
r_b = 6 * m
rad = math.pi * (r_a-r_b)/180
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(rad))
print(ans)

Solution (Python):
from collections import Counter
import sys
import math

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    a, b, h, m = map(int, input().split())
    x1 = a * math.cos(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
    y1 = a * math.sin(2 * math.pi * (h % 12 / 12 + m / 60 / 12))
    x2 = b * math.cos(2 * math.pi * (m / 60))
    y2 = b * math.sin(2 * math.pi * (m / 60))

    print(((x1 - x2)**2 + (y1 - y2)**2)**(1/2))


main()

Solution (Python):
import math


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

    print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(((h+m/60)/12-m/60)*360))))


if __name__ == '__main__':
    main()

Solution (Python):
import math

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

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


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

print(ans)

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

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

long = 6.0*M
short = 30.0*H+0.50*M

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

Solution (Python):
import math

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

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

    return


if __name__ == '__main__':
    main()

Solution (Python):
import math

A, B, H, M = list(map(int, input().split()))
rad = ((H / 12) - (M * 11 / 720)) * 2 * math.pi

ans = ((A ** 2) + (B ** 2) - (2 * A * B * math.cos(rad))) ** (1 / 2)
print(ans)

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

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

Solution (Python):
import math

A,B,H,M = map(int,input().split())
x = H*60+M
y = x/2
z = 6*M
a = abs(y-z)
if a > 180:
    a = 360 - a
c_2 = A**2 + B**2 - 2*A*B*(math.cos(math.radians(a)))
print(math.sqrt(c_2))

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

deg_m = (m / 60) * 360
deg_h = ((60 * h + m) / 720) * 360
deg = abs(deg_h - deg_m)
deg = math.radians(min(360 - deg, deg))
x2 = b ** 2 + a ** 2 - 2 * b * a * math.cos(deg)

print(x2**0.5)

Solution (Python):
import numpy as np
A,B,H,M = map(int,input().split())
pi = np.pi
h_angle = (H + M/60) * 2*pi / 12
m_angle = M * 2 * pi / 60
h_x = A * np.cos(h_angle)
h_y = A * np.sin(h_angle)
m_x = B * np.cos(m_angle)
m_y = B*np.sin(m_angle)
print(np.sqrt((h_x - m_x) ** 2 + (h_y - m_y) ** 2))

Solution (Python):
import math

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

omg_s = math.pi / 360
omg_l = math.pi / 30

tht = (60*h + m)*omg_s - m*omg_l

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

Solution (Python):
import math

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

h_deg = (60 * h + m) * (360 / (60*12))
m_deg = m * (360 / 60)
deg = abs(h_deg-m_deg)
rad = math.radians(deg)

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

print(math.sqrt(c))

Solution (Python):
import math
a, b, h, m = map(int,input().split())
m_rad = m/60 * 360
h_rad = (h/12 * 360) + (m/60 * 360/12)
rad = abs(m_rad - h_rad)
ans = (a**2 + b**2) - (2 * a * b * math.cos(math.radians(rad)))
print(math.sqrt(ans))

Solution (Python):
import math
A,B,H,M=map(int,input().split())
s=float(max(6*M,30*H+1/2*M)-min(6*M,30*H+1/2*M))/180*math.pi
print(float(math.sqrt(A**2+B**2-2*A*B*math.cos(s))))

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

s=float(max(6*M,30*H+1/2*M)-min(6*M,30*H+1/2*M))/180*math.pi
S=float(min(s,abs(s-180))/180*math.pi)
print(float(math.sqrt(A**2+B**2-2*A*B*math.cos(s))))

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

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

th1 = H * 30 + 0.5 * M
th2 = M * 6

theta = min( abs( th1 - th2 ) , 360 - abs( th1 - th2 ))
if theta == 180.0:
    print(A+B)
    sys.exit()
theta = radians(theta)
ans = sqrt( (B * sin(theta))**2 + ( B*cos(theta) - A )**2 )
print(ans)

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

wa=math.pi*2/60/12
wb=math.pi*2/60
theta=(wb-wa)*(H*60+M)%(2*math.pi)

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

Solution (Python):
import math
import numpy as np


def rot_rev(t, v):
    R = np.array([[ np.cos(t), np.sin(t)],
                  [-np.sin(t), np.cos(t)]])
    return np.dot(R, v)

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


H_rad = ((H * 60 + M) / (12 * 60)) * 2 * np.pi
M_rad = (M / 60) * 2 * np.pi

P_A = (0, A)
P_B = (0, B)

rot_A = rot_rev(H_rad, P_A)
rot_B = rot_rev(M_rad, P_B)

print(np.linalg.norm(rot_A - rot_B))

Solution (Python):
import sys
import math
from decimal import Decimal
def input(): return sys.stdin.readline().rstrip()

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

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

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
H=30*h+0.5*m
M=6*m
C=a**2+b**2-2*a*b*math.cos(math.radians(H-M))
print(math.sqrt(C))

Solution (Python):
import math

x = list(map(int,input().split()))

A = x[0]
B = x[1]
H = x[2]
M = x[3]

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

z = math.sqrt(A**2+B**2-2*A*B*math.cos(y))

print(z)

Solution (Python):
import math
def colon():
    A, B, H, M = map(int,input().split())
    h = 30 * H
    h = h - 5.5 * M
    h = min(h, 360 - h)
    h = h * math.pi / 180
    res = A**2 + B**2 - 2*A*B*math.cos(h)
    print(res**0.5)
    
colon()

Solution (Python):
import math
[A, B, H, M] = [int(i) for i in input().split()]
x = 5.5*(60*H + M)
c = A**2 + B**2 -2*A*B*math.cos(math.radians(x))
print(c**0.5)