import java.util.Scanner;

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

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double theta1 = 30.0d * (h + (m / 60.0D));
		double theta2 = 6.0d * m;

		double theta = Math.toRadians(theta2 - theta1);
		double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta));

		System.out.println(String.format("%.20f", c));
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double theta1 = 30.0d * (h + (m / 60.0D));
		double theta2 = 6.0d * m;

		double theta = Math.toRadians(theta2 - theta1);
		double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta));

		System.out.println(String.format("%.20f", c));
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double theta1 = 30.0d * (h + (m / 60.0D));
		double theta2 = 6.0d * m;

		double theta = Math.toRadians(theta2 - theta1);
		double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta));

		System.out.println(String.format("%.20f", c));
	} main {
		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double theta1 = 30.0d * (h + (m / 60.0D));
		double theta2 = 6.0d * m;

		double theta = Math.toRadians(theta2 - theta1);
		double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta));

		System.out.println(String.format("%.20f", c));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double a = sc.nextDouble(); a sc.nextDouble() sc.nextDouble sc double b = sc.nextDouble(); b sc.nextDouble() sc.nextDouble sc double h = sc.nextDouble(); h sc.nextDouble() sc.nextDouble sc double m = sc.nextDouble(); m sc.nextDouble() sc.nextDouble sc double theta1 = 30.0d * (h + (m / 60.0D)); theta1 30.0d * (h + (m / 60.0D)) 30.0d (h + (m / 60.0D)) h (m / 60.0D) m 60.0D double theta2 = 6.0d * m; theta2 6.0d * m 6.0d m double theta = Math.toRadians(theta2 - theta1); theta Math.toRadians(theta2 - theta1) Math.toRadians Math theta2 - theta1 theta2 theta1 double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta)); c Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta)) Math.sqrt Math Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta) Math.pow(a, 2.0D) + Math.pow(b, 2.0D) Math.pow(a, 2.0D) Math.pow Math a 2.0D Math.pow(b, 2.0D) Math.pow Math b 2.0D 2.0D * a * b * Math.cos(theta) b 2.0D * a * b * Math.cos(theta) 2.0D a b Math.cos(theta) Math.cos Math theta System.out.println(String.format("%.20f", c)) System.out.println System.out System System.out String.format("%.20f", c) String.format String "%.20f" c String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double theta1 = 30.0d * (h + (m / 60.0D));
		double theta2 = 6.0d * m;

		double theta = Math.toRadians(theta2 - theta1);
		double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta));

		System.out.println(String.format("%.20f", c));
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double theta1 = 30.0d * (h + (m / 60.0D));
		double theta2 = 6.0d * m;

		double theta = Math.toRadians(theta2 - theta1);
		double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta));

		System.out.println(String.format("%.20f", c));
	}
} Main
import java.util.Scanner;

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

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();

		double theta1 = 30.0d * (h + (m / 60.0D));
		double theta2 = 6.0d * m;

		double theta = Math.toRadians(theta2 - theta1);
		double c = Math.sqrt(Math.pow(a, 2.0D) + Math.pow(b, 2.0D) - 2.0D * a * b * Math.cos(theta));

		System.out.println(String.format("%.20f", c));
	}
}
