import java.util.*;
class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    double thetaH = 2*Math.PI*(H+M/60)/12;
    double thetaM = 2*Math.PI*M/60;
    double theta = Math.abs(thetaH-thetaM);
    double distance = Math.sqrt(A*A + B*B -2*A*B*Math.cos(theta));
    System.out.println(distance);
  }
} import java.util.*; util.* java class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    double thetaH = 2*Math.PI*(H+M/60)/12;
    double thetaM = 2*Math.PI*M/60;
    double theta = Math.abs(thetaH-thetaM);
    double distance = Math.sqrt(A*A + B*B -2*A*B*Math.cos(theta));
    System.out.println(distance);
  }
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args){
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    double thetaH = 2*Math.PI*(H+M/60)/12;
    double thetaM = 2*Math.PI*M/60;
    double theta = Math.abs(thetaH-thetaM);
    double distance = Math.sqrt(A*A + B*B -2*A*B*Math.cos(theta));
    System.out.println(distance);
  } main {
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    double thetaH = 2*Math.PI*(H+M/60)/12;
    double thetaM = 2*Math.PI*M/60;
    double theta = Math.abs(thetaH-thetaM);
    double distance = Math.sqrt(A*A + B*B -2*A*B*Math.cos(theta));
    System.out.println(distance);
  } 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 thetaH = 2*Math.PI*(H+M/60)/12; thetaH 2*Math.PI*(H+M/60)/12 2*Math.PI*(H+M/60) 2*Math.PI*(H+M/60) 2 Math.PI Math Math.PI (H+M/60) H M/60 M 60 12 double thetaM = 2*Math.PI*M/60; thetaM 2*Math.PI*M/60 2*Math.PI*M 2*Math.PI*M 2 Math.PI Math Math.PI M 60 double theta = Math.abs(thetaH-thetaM); theta Math.abs(thetaH-thetaM) Math.abs Math thetaH-thetaM thetaH thetaM double distance = Math.sqrt(A*A + B*B -2*A*B*Math.cos(theta)); distance Math.sqrt(A*A + B*B -2*A*B*Math.cos(theta)) Math.sqrt Math A*A + B*B -2*A*B*Math.cos(theta) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(theta) B 2*A*B*Math.cos(theta) 2 A B Math.cos(theta) Math.cos Math theta System.out.println(distance) System.out.println System.out System System.out distance String[] args args
import java.util.*;
class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    double A = sc.nextDouble();
    double B = sc.nextDouble();
    double H = sc.nextDouble();
    double M = sc.nextDouble();
    double thetaH = 2*Math.PI*(H+M/60)/12;
    double thetaM = 2*Math.PI*M/60;
    double theta = Math.abs(thetaH-thetaM);
    double distance = Math.sqrt(A*A + B*B -2*A*B*Math.cos(theta));
    System.out.println(distance);
  }
}