import java.lang.Math._
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val A, B, H, M = sc.nextDouble
  val hour = Polar(A, PI * (H + M / 60d) / 6d)
  val minute = Polar(B, PI * M / 30d)
  println(hour.rectangular)
  println(minute.rectangular)
  println(hour distance minute)
}

case class Polar(r: Double, θ: Double) {
  lazy val rectangular: Rectangular =
    Rectangular(r * cos(θ), r * sin(θ))
  def distance(that: Polar): Double =
    rectangular distance that.rectangular
}

case class Rectangular(x: Double, y: Double) {
  def distance(that: Rectangular): Double = {
    val dx = x - that.x
    val dy = y - that.y
    sqrt(dx * dx + dy * dy)
  }
}
