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

int main()
{
    int a,b,h,m;
    int jh,jm,c;
    double result;
    scanf("%d %d %d %d",&a,&b,&h,&m);
    jh=5*h*6;
    jm=m*6;
    if(abs(jh-jm)>180)
        c=360-abs(jh-jm);
    else
        c=abs(jh-jm);
    printf("%d\n",c);
    if(abs(jh-jm)==180){
            result=a+b;
    }
    else if(abs(jh-jm)==0){
        result=abs(a-b);
    }
    else{
        result=a*a+b*b-2*a*b*cos(c*3.14159265/180);
    }
    printf("%.9f",sqrt(result));
    return 0;
}
