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();

        double angle = Math.abs(M*6.0 - 0.5*(60*H + M));
        double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(length);
    }
} 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();

        double angle = Math.abs(M*6.0 - 0.5*(60*H + M));
        double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(length);
    }
} 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();

        double angle = Math.abs(M*6.0 - 0.5*(60*H + M));
        double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(length);
    } main {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int H = scanner.nextInt();
        int M = scanner.nextInt();

        double angle = Math.abs(M*6.0 - 0.5*(60*H + M));
        double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(length);
    } 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 angle = Math.abs(M*6.0 - 0.5*(60*H + M)); angle Math.abs(M*6.0 - 0.5*(60*H + M)) Math.abs Math M*6.0 - 0.5*(60*H + M) M*6.0 M 6.0 0.5*(60*H + M) 0.5 (60*H + M) 60*H 60 H M double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle))); length Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle))) Math.sqrt Math Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)) Math.pow(A, 2) + Math.pow(B, 2) Math.pow(A, 2) Math.pow Math A 2 Math.pow(B, 2) Math.pow Math B 2 2*A*B*Math.cos(Math.toRadians(angle)) B 2*A*B*Math.cos(Math.toRadians(angle)) 2 A B Math.cos(Math.toRadians(angle)) Math.cos Math Math.toRadians(angle) Math.toRadians Math angle System.out.println(length) System.out.println System.out System System.out length 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();

        double angle = Math.abs(M*6.0 - 0.5*(60*H + M));
        double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(length);
    }
} 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();

        double angle = Math.abs(M*6.0 - 0.5*(60*H + M));
        double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(length);
    }
} 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();

        double angle = Math.abs(M*6.0 - 0.5*(60*H + M));
        double length = Math.sqrt(Math.pow(A, 2) + Math.pow(B, 2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(length);
    }
}
