import Foundation


func calcPosition(length: Int, radian: Float) -> (x: Float, y: Float) {
    switch radian {
    case 0.0:
        return (Float(0), Float(length))
    case 90.0:
        return (Float(length), Float(0))
    case 180.0:
        return (Float(0), -Float(length))
    case 270.0:
        return (Float(length), Float(0))
    default:
        return (Float(length) * sin(radian), Float(length) * cos(radian))
    }
}


let line = readLine()!.components(separatedBy: " ")

let A = Int(line[0])!
let B = Int(line[1])!
let H = Float(line[2])!
let M = Float(line[3])!

let T = H * 60.0 + M

let a = T / 720.0 * 360.0
let b = M / 60.0 * 360.0

let (ax, ay) = calcPosition(length: A, radian: a)
let (bx, by) = calcPosition(length: B, radian: b)

print(ax)
print(bx)
print(ay)
print(by)

let distance = sqrt(pow(ax - bx, 2) + pow(ay - by, 2))
print(distance)
