module Main where

import           Control.Arrow              ((>>>))
import           Control.Monad              (join)
import           Data.ByteString.Lazy.Char8 as C
import           Data.List.Split            (chunksOf)
import           Data.Maybe                 (fromJust)
import           Text.Printf                (printf)

main = C.interact $ C.lines >>> Prelude.map C.words >>>
    Prelude.map (Prelude.map readInt) >>> join >>> solve >>> C.unlines
        where
            readInt = C.readInt >>> fromJust >>> fst

solve :: [Int] -> [C.ByteString]
solve [a,b,h,m] = let [af, bf, hf, mf] = Prelude.map (fromIntegral :: Int -> Double) [a,b,h,m]
                      rad = 2.0 * pi * ((hf / 12.0) + ((mf / 60.0) / 12.0) - (mf / 60.0))
                      c_2 = af*af + bf*bf - 2.0 * af * bf * cos rad in
                      [C.pack $ printf "%.10f" (sqrt c_2) :: C.ByteString]
solve _         = error "bad arg shape"

