#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int asc(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int dis(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    double a, b;
    double h, m;
    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    double rad;
    rad = 2 * M_PI * (m / 60.0 - (h + m / 60.0) / 12.0);
    printf("%lf\n", cos(rad));
    printf("%.10lf", sqrt(a * a + b * b - 2 * a * b * cos(rad)));
    return 0;
}