import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        // H * (360 / 12) + M * (30 / 60);
        double theta1 = Math.toRadians(H * 30.0 + M * 0.5);
        // M * (360 / 60);
        double theta2 = Math.toRadians(M * 6.0);
        double dist = 0.0;
        if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        }
        System.out.println(dist);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        // H * (360 / 12) + M * (30 / 60);
        double theta1 = Math.toRadians(H * 30.0 + M * 0.5);
        // M * (360 / 60);
        double theta2 = Math.toRadians(M * 6.0);
        double dist = 0.0;
        if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        }
        System.out.println(dist);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        // H * (360 / 12) + M * (30 / 60);
        double theta1 = Math.toRadians(H * 30.0 + M * 0.5);
        // M * (360 / 60);
        double theta2 = Math.toRadians(M * 6.0);
        double dist = 0.0;
        if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        }
        System.out.println(dist);
    } main {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        // H * (360 / 12) + M * (30 / 60);
        double theta1 = Math.toRadians(H * 30.0 + M * 0.5);
        // M * (360 / 60);
        double theta2 = Math.toRadians(M * 6.0);
        double dist = 0.0;
        if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        }
        System.out.println(dist);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int H = scanner.nextInt(); H scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner double theta1 = Math.toRadians(H * 30.0 + M * 0.5); theta1 Math.toRadians(H * 30.0 + M * 0.5) Math.toRadians Math H * 30.0 + M * 0.5 H * 30.0 H 30.0 M * 0.5 M 0.5 double theta2 = Math.toRadians(M * 6.0); theta2 Math.toRadians(M * 6.0) Math.toRadians Math M * 6.0 M 6.0 double dist = 0.0; dist 0.0 if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        } theta1 > theta2 theta1 theta2 {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2)) dist Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2)) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2) A * A + B * B A * A A A B * B B B 2 * A * B * Math.cos(theta1 - theta2) B 2 * A * B * Math.cos(theta1 - theta2) 2 A B Math.cos(theta1 - theta2) Math.cos Math theta1 - theta2 theta1 theta2 {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        } dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1)) dist Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1)) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1) A * A + B * B A * A A A B * B B B 2 * A * B * Math.cos(theta2 - theta1) B 2 * A * B * Math.cos(theta2 - theta1) 2 A B Math.cos(theta2 - theta1) Math.cos Math theta2 - theta1 theta2 theta1 System.out.println(dist) System.out.println System.out System System.out dist String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        // H * (360 / 12) + M * (30 / 60);
        double theta1 = Math.toRadians(H * 30.0 + M * 0.5);
        // M * (360 / 60);
        double theta2 = Math.toRadians(M * 6.0);
        double dist = 0.0;
        if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        }
        System.out.println(dist);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        // H * (360 / 12) + M * (30 / 60);
        double theta1 = Math.toRadians(H * 30.0 + M * 0.5);
        // M * (360 / 60);
        double theta2 = Math.toRadians(M * 6.0);
        double dist = 0.0;
        if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        }
        System.out.println(dist);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        // H * (360 / 12) + M * (30 / 60);
        double theta1 = Math.toRadians(H * 30.0 + M * 0.5);
        // M * (360 / 60);
        double theta2 = Math.toRadians(M * 6.0);
        double dist = 0.0;
        if (theta1 > theta2) {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta1 - theta2));
        } else {
            dist = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(theta2 - theta1));
        }
        System.out.println(dist);
    }
}
