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


//using ll = long long;
int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(double a, double b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	int a, b, h, m;
	scanf("%d%d%d%d",&a,&b,&h,&m);
	double hunsin = 6 * m;
	double jisin = 30 * h + m*0.5;
	double sita = fabs(hunsin - jisin);
	sita = min(sita, 360.0 - sita);
	double rad = sita*3.141592653589793 / 180.0;
	//printf("%lf\n", 90*3.14/180.0);
	double ans = a*a + b*b - 2 * a*b*cos(rad);
	printf("%lf\n",cos(rad));
	ans = sqrt(ans);
	printf("%lf",ans);
	return 0;
}