import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a, b, h, m;
        a = in.nextDouble();
        b = in.nextDouble();
        h = in.nextDouble();
        m = in.nextDouble();
        in.close();
        double h_angle = 0.5 * (h * 60 + m);
        double m_angle = 6 * m;
        double angle = Math.abs(h_angle - m_angle);
        angle = Math.min(angle, 360 - angle);
        double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180));
        System.out.printf("%.20f\n", res);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a, b, h, m;
        a = in.nextDouble();
        b = in.nextDouble();
        h = in.nextDouble();
        m = in.nextDouble();
        in.close();
        double h_angle = 0.5 * (h * 60 + m);
        double m_angle = 6 * m;
        double angle = Math.abs(h_angle - m_angle);
        angle = Math.min(angle, 360 - angle);
        double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180));
        System.out.printf("%.20f\n", res);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a, b, h, m;
        a = in.nextDouble();
        b = in.nextDouble();
        h = in.nextDouble();
        m = in.nextDouble();
        in.close();
        double h_angle = 0.5 * (h * 60 + m);
        double m_angle = 6 * m;
        double angle = Math.abs(h_angle - m_angle);
        angle = Math.min(angle, 360 - angle);
        double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180));
        System.out.printf("%.20f\n", res);
    } main {
        Scanner in = new Scanner(System.in);
        double a, b, h, m;
        a = in.nextDouble();
        b = in.nextDouble();
        h = in.nextDouble();
        m = in.nextDouble();
        in.close();
        double h_angle = 0.5 * (h * 60 + m);
        double m_angle = 6 * m;
        double angle = Math.abs(h_angle - m_angle);
        angle = Math.min(angle, 360 - angle);
        double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180));
        System.out.printf("%.20f\n", res);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) double a a b b h h m; m a = in.nextDouble() a in.nextDouble() in.nextDouble in b = in.nextDouble() b in.nextDouble() in.nextDouble in h = in.nextDouble() h in.nextDouble() in.nextDouble in m = in.nextDouble() m in.nextDouble() in.nextDouble in in.close() in.close in double h_angle = 0.5 * (h * 60 + m); h_angle 0.5 * (h * 60 + m) 0.5 (h * 60 + m) h * 60 h 60 m double m_angle = 6 * m; m_angle 6 * m 6 m double angle = Math.abs(h_angle - m_angle); angle Math.abs(h_angle - m_angle) Math.abs Math h_angle - m_angle h_angle m_angle angle = Math.min(angle, 360 - angle) angle Math.min(angle, 360 - angle) Math.min Math angle 360 - angle 360 angle double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180)); res Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180)) Math.sqrt Math a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180) a*a + b*b a*a a a b*b b b 2*a*b*Math.cos(angle*Math.PI/180) b 2*a*b*Math.cos(angle*Math.PI/180) 2 a b Math.cos(angle*Math.PI/180) Math.cos Math angle*Math.PI/180 angle*Math.PI angle Math.PI Math Math.PI 180 System.out.printf("%.20f\n", res) System.out.printf System.out System System.out "%.20f\n" res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a, b, h, m;
        a = in.nextDouble();
        b = in.nextDouble();
        h = in.nextDouble();
        m = in.nextDouble();
        in.close();
        double h_angle = 0.5 * (h * 60 + m);
        double m_angle = 6 * m;
        double angle = Math.abs(h_angle - m_angle);
        angle = Math.min(angle, 360 - angle);
        double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180));
        System.out.printf("%.20f\n", res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a, b, h, m;
        a = in.nextDouble();
        b = in.nextDouble();
        h = in.nextDouble();
        m = in.nextDouble();
        in.close();
        double h_angle = 0.5 * (h * 60 + m);
        double m_angle = 6 * m;
        double angle = Math.abs(h_angle - m_angle);
        angle = Math.min(angle, 360 - angle);
        double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180));
        System.out.printf("%.20f\n", res);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a, b, h, m;
        a = in.nextDouble();
        b = in.nextDouble();
        h = in.nextDouble();
        m = in.nextDouble();
        in.close();
        double h_angle = 0.5 * (h * 60 + m);
        double m_angle = 6 * m;
        double angle = Math.abs(h_angle - m_angle);
        angle = Math.min(angle, 360 - angle);
        double res = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(angle*Math.PI/180));
        System.out.printf("%.20f\n", res);
    }
}
