import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
		int M = sc.nextInt();

		//ここから角度を求める計算
		double minAngle = (double)M * 6;
		double onlyHour = (double)H * 30;
		double hourAngle = onlyHour + (double)M * 0.5;
		double angle = Math.abs(minAngle - hourAngle);
		if(angle > 180)
		angle = 360 - angle;

		//ここから長さを求める計算
		double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.println(ans);
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
		int M = sc.nextInt();

		//ここから角度を求める計算
		double minAngle = (double)M * 6;
		double onlyHour = (double)H * 30;
		double hourAngle = onlyHour + (double)M * 0.5;
		double angle = Math.abs(minAngle - hourAngle);
		if(angle > 180)
		angle = 360 - angle;

		//ここから長さを求める計算
		double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
		int M = sc.nextInt();

		//ここから角度を求める計算
		double minAngle = (double)M * 6;
		double onlyHour = (double)H * 30;
		double hourAngle = onlyHour + (double)M * 0.5;
		double angle = Math.abs(minAngle - hourAngle);
		if(angle > 180)
		angle = 360 - angle;

		//ここから長さを求める計算
		double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
		int M = sc.nextInt();

		//ここから角度を求める計算
		double minAngle = (double)M * 6;
		double onlyHour = (double)H * 30;
		double hourAngle = onlyHour + (double)M * 0.5;
		double angle = Math.abs(minAngle - hourAngle);
		if(angle > 180)
		angle = 360 - angle;

		//ここから長さを求める計算
		double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int H = sc.nextInt(); H sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc double minAngle = (double)M * 6; minAngle (double)M * 6 (double)M 6 double onlyHour = (double)H * 30; onlyHour (double)H * 30 (double)H 30 double hourAngle = onlyHour + (double)M * 0.5; hourAngle onlyHour + (double)M * 0.5 onlyHour (double)M * 0.5 (double)M 0.5 double angle = Math.abs(minAngle - hourAngle); angle Math.abs(minAngle - hourAngle) Math.abs Math minAngle - hourAngle minAngle hourAngle if(angle > 180)
		angle = 360 - angle; angle > 180 angle 180 angle = 360 - angle angle 360 - angle 360 angle double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle))); ans Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle))) Math.sqrt Math A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)) A * A + B * B A * A A A B * B B B 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(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
		int M = sc.nextInt();

		//ここから角度を求める計算
		double minAngle = (double)M * 6;
		double onlyHour = (double)H * 30;
		double hourAngle = onlyHour + (double)M * 0.5;
		double angle = Math.abs(minAngle - hourAngle);
		if(angle > 180)
		angle = 360 - angle;

		//ここから長さを求める計算
		double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
		int M = sc.nextInt();

		//ここから角度を求める計算
		double minAngle = (double)M * 6;
		double onlyHour = (double)H * 30;
		double hourAngle = onlyHour + (double)M * 0.5;
		double angle = Math.abs(minAngle - hourAngle);
		if(angle > 180)
		angle = 360 - angle;

		//ここから長さを求める計算
		double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.println(ans);
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
		int M = sc.nextInt();

		//ここから角度を求める計算
		double minAngle = (double)M * 6;
		double onlyHour = (double)H * 30;
		double hourAngle = onlyHour + (double)M * 0.5;
		double angle = Math.abs(minAngle - hourAngle);
		if(angle > 180)
		angle = 360 - angle;

		//ここから長さを求める計算
		double ans = Math.sqrt(A * A + B * B - 2 * A * B * Math.cos(Math.toRadians(angle)));
		System.out.println(ans);
    }
}