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 in C# (.NET Core 3.1.201) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace _168
{
    class Program
    {
        static void Main(string[] args)
        {

            C();
        }

        public static void A()
        {
            int x = int.Parse(Console.ReadLine()) % 10;
            if (x == 2 || x == 4 || x == 5 || x == 7 || x == 9)
            {
                Console.WriteLine("hon");
            }
            if (x == 0 || x == 6 || x == 1 || x == 8)
            {
                Console.WriteLine("pon");
            }
            if (x == 3)
            {
                Console.WriteLine("bon");
            }
        }

        public static void B()
        {
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if(s.Length > k)
            {
                Console.WriteLine(s.Substring(0,k) + "...");
            }
            else
            {
                Console.WriteLine(s);
            }
        }

        public static void C()
        {
            string[] num = Console.ReadLine().Split(" ");
            int a = int.Parse(num[0]);
            int b = int.Parse(num[1]);
            int h = int.Parse(num[2]);
            int m = int.Parse(num[3]);

            int min = h * 60 + m;

            double h_do = 0.5 * (min % 720);
            double m_do = 6 * (min % 60);

            double sa = Math.Abs(h_do - m_do);
            //if (sa > 180) sa = 180 - sa;

            double cos = Math.Abs(Math.Cos(sa * (Math.PI / 180)));

            Console.WriteLine(Math.Sqrt(a*a + b*b -2*a*b * cos));
        }

        public static void D()
        {
            int n = int.Parse(Console.ReadLine());
            List<iwasi> iwasis = new List<iwasi>();
            for(int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split(" ");
                iwasis.Add(new iwasi(int.Parse(s[0]), int.Parse(s[1])));
            }
            int count = 0;

        }

        public class iwasi
        {
            public int a;
            public int b;

            public iwasi(int a,int b)
            {
                this.a = a;
                this.b = b;
            }
        }
    }
}