#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define PI 3.14159265358979
int main()
{
	double  c, h, m,d;
	int a, b;
	scanf("%d%d%lf%lf", &a, &b, &h, &m);
	d = abs(30.0 * h - 6.0 * m+m/2.0);
	if (d > 180)
	{
		d = 360.0 - d;
	}
	printf("%lf\n", cos(d * PI / 180.0));
	if (d == 0.0)
	{
		printf("%d",abs(a-b));
	}
	else if (d == 180.0)
	{
		printf("%d", a + b);
	}
	else
	{
		c = sqrt(a * a + b * b - 2.0 * a * b * cos(d * PI / 180.0));
		printf("%lf", c);
	}
    return 0;
}