
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);

    static void run() {
        int A = in.nextInt(), B = in.nextInt(), H = in.nextInt(), M = in.nextInt();
        double m = 2.0 * Math.PI * M / 60;
        double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12);
        double a = Math.max(m, h) - Math.min(m, h);
        if (a >= Math.PI) a = 2 * Math.PI - a;
        double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a));
        System.out.println(d);
    }

    public static void main(String[] args) {
        run();
    }
} import java.util.Scanner; Scanner java.util public class Main {
    static Scanner in = new Scanner(System.in);

    static void run() {
        int A = in.nextInt(), B = in.nextInt(), H = in.nextInt(), M = in.nextInt();
        double m = 2.0 * Math.PI * M / 60;
        double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12);
        double a = Math.max(m, h) - Math.min(m, h);
        if (a >= Math.PI) a = 2 * Math.PI - a;
        double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a));
        System.out.println(d);
    }

    public static void main(String[] args) {
        run();
    }
} Main static Scanner in = new Scanner(System.in); in new Scanner(System.in) static void run() {
        int A = in.nextInt(), B = in.nextInt(), H = in.nextInt(), M = in.nextInt();
        double m = 2.0 * Math.PI * M / 60;
        double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12);
        double a = Math.max(m, h) - Math.min(m, h);
        if (a >= Math.PI) a = 2 * Math.PI - a;
        double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a));
        System.out.println(d);
    } run {
        int A = in.nextInt(), B = in.nextInt(), H = in.nextInt(), M = in.nextInt();
        double m = 2.0 * Math.PI * M / 60;
        double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12);
        double a = Math.max(m, h) - Math.min(m, h);
        if (a >= Math.PI) a = 2 * Math.PI - a;
        double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a));
        System.out.println(d);
    } int A = in.nextInt() A in.nextInt() in.nextInt in B = in.nextInt() B in.nextInt() in.nextInt in H = in.nextInt() H in.nextInt() in.nextInt in M = in.nextInt(); M in.nextInt() in.nextInt in double m = 2.0 * Math.PI * M / 60; m 2.0 * Math.PI * M / 60 2.0 * Math.PI * M 2.0 * Math.PI * M 2.0 Math.PI Math Math.PI M 60 double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12); h 2.0 * Math.PI * (H * 60 + M) / (60 * 12) 2.0 * Math.PI * (H * 60 + M) 2.0 * Math.PI * (H * 60 + M) 2.0 Math.PI Math Math.PI (H * 60 + M) H * 60 H 60 M (60 * 12) 60 12 double a = Math.max(m, h) - Math.min(m, h); a Math.max(m, h) - Math.min(m, h) Math.max(m, h) Math.max Math m h Math.min(m, h) Math.min Math m h if (a >= Math.PI) a = 2 * Math.PI - a; a >= Math.PI a Math.PI Math Math.PI a = 2 * Math.PI - a a 2 * Math.PI - a 2 * Math.PI 2 Math.PI Math Math.PI a double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a)); d Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a)) Math.sqrt Math A*A + B*B - 2*A*B*Math.cos(a) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(a) B 2*A*B*Math.cos(a) 2 A B Math.cos(a) Math.cos Math a System.out.println(d) System.out.println System.out System System.out d public static void main(String[] args) {
        run();
    } main {
        run();
    } run() run String[] args args public class Main {
    static Scanner in = new Scanner(System.in);

    static void run() {
        int A = in.nextInt(), B = in.nextInt(), H = in.nextInt(), M = in.nextInt();
        double m = 2.0 * Math.PI * M / 60;
        double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12);
        double a = Math.max(m, h) - Math.min(m, h);
        if (a >= Math.PI) a = 2 * Math.PI - a;
        double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a));
        System.out.println(d);
    }

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

    static void run() {
        int A = in.nextInt(), B = in.nextInt(), H = in.nextInt(), M = in.nextInt();
        double m = 2.0 * Math.PI * M / 60;
        double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12);
        double a = Math.max(m, h) - Math.min(m, h);
        if (a >= Math.PI) a = 2 * Math.PI - a;
        double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a));
        System.out.println(d);
    }

    public static void main(String[] args) {
        run();
    }
} Main

import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);

    static void run() {
        int A = in.nextInt(), B = in.nextInt(), H = in.nextInt(), M = in.nextInt();
        double m = 2.0 * Math.PI * M / 60;
        double h = 2.0 * Math.PI * (H * 60 + M) / (60 * 12);
        double a = Math.max(m, h) - Math.min(m, h);
        if (a >= Math.PI) a = 2 * Math.PI - a;
        double d = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(a));
        System.out.println(d);
    }

    public static void main(String[] args) {
        run();
    }
}
