Scanf.scanf "%f %f %f %f" (fun a b h m ->
    let pi = 3.1415926535897932384626 in
    let hdeg = (h +. m /. 60.) /. 6. *. pi in
    let mdeg = m /. 30. *. pi in

    let x1 = a *. cos hdeg in
    let y1 = a *. sin hdeg in
    let x2 = b *. cos mdeg in
    let y2 = b *. sin mdeg in

    let f g h = (g -. h) *. (g -. h) in
    let ans = sqrt (f x1 x2 +. f y1 y2) in
    Printf.printf "%.10f\n" ans
)
