import java.util.*;
import java.math.*;

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();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  }
} import java.util.*; util.* java import java.math.*; math.* 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();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  }
} 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();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  } main {
    
    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    int H = sc.nextInt();
    int M = sc.nextInt();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  } 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 if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   } A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59 M>=0 H<=11 H>=0 B<=1000 B>=1 A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59 A>=1 A 1 A<=1000 A 1000 B>=1 B 1 B<=1000 B 1000 H>=0 H 0 H<=11 H 11 M>=0 M 0 M<=59 M 59 {
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   } double hm = Math.abs(30*H +M*0.5-M*6); hm Math.abs(30*H +M*0.5-M*6) Math.abs Math 30*H +M*0.5-M*6 30*H +M*0.5 30*H 30 H M*0.5 M 0.5 M*6 M 6 if(hm >= 180){
      hm = 360.0 - hm;
    } hm >= 180 hm 180 {
      hm = 360.0 - hm;
    } hm = 360.0 - hm hm 360.0 - hm 360.0 hm double ans = 0; ans 0 if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    } hm == 90 hm 90 {
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    } int I  = A*A + B*B; I A*A + B*B A*A A A B*B B B ans = Math.sqrt(I) ans Math.sqrt(I) Math.sqrt Math I System.out.println(ans) System.out.println System.out System System.out ans {
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    } ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm)) ans A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm)) A*A + B*B A*A A A B*B B B 2*A*B*Math.cos(Math.toRadians(hm)) B 2*A*B*Math.cos(Math.toRadians(hm)) 2 A B Math.cos(Math.toRadians(hm)) Math.cos Math Math.toRadians(hm) Math.toRadians Math hm System.out.println(Math.sqrt(ans)) System.out.println System.out System System.out Math.sqrt(ans) Math.sqrt Math ans {
     System.out.println("入力条件に違反しています");  
   } System.out.println("入力条件に違反しています") System.out.println System.out System System.out "入力条件に違反しています" 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();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  }
} 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();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  }
} Main
import java.util.*;
import java.math.*;

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();
    
   if(A>=1 && A<=1000 && B>=1 && B<=1000 
      && H>=0 && H<=11 && M>=0 && M<=59){
    double hm = Math.abs(30*H +M*0.5-M*6);
    if(hm >= 180){
      hm = 360.0 - hm;
    }
   
    double ans = 0;
    if(hm == 90){
      int I  = A*A + B*B;
      ans = Math.sqrt(I);
      //String answer = String.format("%.20f",ans);
      //System.out.println(answer);
      System.out.println(ans);  
    }else{
     ans =  A*A + B*B - 2*A*B*Math.cos(Math.toRadians(hm));
     //String answer = String.format("%.20f",Math.sqrt(ans));
     //System.out.println(answer);
     System.out.println(Math.sqrt(ans));  
    }    
   }else{
     System.out.println("入力条件に違反しています");  
   }
  }
}