#include<stdio.h>
#include<math.h>

int main(){
  
  long double a,b,h,m,ans;
  long double rad1,rad2,rad3;
  
  
  scanf("%Lf%Lf%Lf%Lf",&a,&b,&h,&m);
  
  rad1 = (h/12 + m/12/60) * 2*M_PI;
  rad2 = m/60 * 2*M_PI;
  rad3 = rad2 - rad1;
  
  printf("rad1=%Lf rad2=%Lf rad3=%Lf\n",rad1,rad2,rad3);
  
  ans = sqrt(a*a + b*b - 2*a*b*cos(rad3));
  
  printf("%.20Lf\n",ans);
  
  return 0;
        
}