import java.util.Scanner;
 
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 cosC = 0;
	    double h = (H * 30) + (M * 0.5);
	    double s = M * 6;
	    if (h > s) { cosC = h - s; } else if (h < s) { cosC = s - h; }
	    
	    // 残りの辺の長さ C2 = A2 + B2 - 2ABcosC
	    double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC)));

	    System.out.println(C);
	    
	  }
} import java.util.Scanner; Scanner java.util 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 cosC = 0;
	    double h = (H * 30) + (M * 0.5);
	    double s = M * 6;
	    if (h > s) { cosC = h - s; } else if (h < s) { cosC = s - h; }
	    
	    // 残りの辺の長さ C2 = A2 + B2 - 2ABcosC
	    double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC)));

	    System.out.println(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 cosC = 0;
	    double h = (H * 30) + (M * 0.5);
	    double s = M * 6;
	    if (h > s) { cosC = h - s; } else if (h < s) { cosC = s - h; }
	    
	    // 残りの辺の長さ C2 = A2 + B2 - 2ABcosC
	    double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC)));

	    System.out.println(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 cosC = 0;
	    double h = (H * 30) + (M * 0.5);
	    double s = M * 6;
	    if (h > s) { cosC = h - s; } else if (h < s) { cosC = s - h; }
	    
	    // 残りの辺の長さ C2 = A2 + B2 - 2ABcosC
	    double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC)));

	    System.out.println(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 cosC = 0; cosC 0 double h = (H * 30) + (M * 0.5); h (H * 30) + (M * 0.5) (H * 30) H 30 (M * 0.5) M 0.5 double s = M * 6; s M * 6 M 6 if (h > s) { cosC = h - s; } else if (h < s) { cosC = s - h; } h > s h s { cosC = h - s; } cosC = h - s cosC h - s h s if (h < s) { cosC = s - h; } h < s h s { cosC = s - h; } cosC = s - h cosC s - h s h double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC))); C Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC))) Math.sqrt Math Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC)) 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(cosC)) B 2*A*B*Math.cos(Math.toRadians(cosC)) 2 A B Math.cos(Math.toRadians(cosC)) Math.cos Math Math.toRadians(cosC) Math.toRadians Math cosC System.out.println(C) System.out.println System.out System System.out C String[] args args
import java.util.Scanner;
 
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 cosC = 0;
	    double h = (H * 30) + (M * 0.5);
	    double s = M * 6;
	    if (h > s) { cosC = h - s; } else if (h < s) { cosC = s - h; }
	    
	    // 残りの辺の長さ C2 = A2 + B2 - 2ABcosC
	    double C = Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(cosC)));

	    System.out.println(C);
	    
	  }
}