program problemC
  implicit none

real(8) :: A,B,H,M
real(8), parameter ::pi=4.0*atan(1.0)
real(8) :: ta, tb, theta, l

read(*,*) A,B,H,M

tb=M*2.0*pi/60.0
ta=H*2.0*pi/12.0+tb/12.0

theta=tb-ta

if (theta>pi) then
  theta=theta-pi
else if (theta < -pi) then
  theta=theta+pi
end if

theta=abs(theta)

l=A**2+B**2
l=l-2.0*A*B*dcos(theta)
l=dsqrt(l)

write(*,*) A,B,H,M
write(*,*) ta*180/pi, tb*180/pi, theta*180/pi
write(*,*) A**2, B**2, dcos(theta)
write(*,*) l


stop
end program
