void main(){
	int a, b, h, m;
	readf("%d %d %d %d\n", &a, &b, &h, &m);
	double angle = abs( PI/6.0*(h.to!double+m.to!double/60.0) - PI*m.to!double/30.0  );
	angle.writeln();
	double ans = sqrt( a^^2 + b^^2 -2*a*b*cos(angle) );
	writefln("%f", ans);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}
