#include<stdio.h>
#include<string.h>
#include<math.h>
#define PI 3.141592653589793238462643
int main(void){
 double a,b,h,m;
 double theta1,theta2,theta;
 scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
 
 theta1 = 0.5 * (h*60.0 + m);
 theta2 = 6.0   * m;
 theta  = fabs(theta1 - theta2);
 
 if(theta > 180.0){
   theta = theta - 180.0;
 }
 printf("theta:%lf\n",theta);
 printf("%.16Lf",sqrtl(a*a+b*b-2.0*a*b*cos(theta/180.0*PI)));
 return 0;
}
