
solve2 n 1 sum d = (2 * sum + 1, 2*d)
solve2 n k sum d 
    | n < k     = solve2 n      next_k  (2 * sum)                (2 * d)
    | otherwise = solve2 (k-1)  next_k ((2 * sum) + n - (k - 1)) (2 * d) -- k - 1 < n 
    where
        next_k = div (k + mod k 2) 2


solve :: [Int] -> Double 
solve (n:k:_) =
    (fromIntegral s) / (fromIntegral d2)
    where
        (s, d) = solve2 n k 0 1
        d2 = div (d * n ) 2


main = interact $ show.solve.map read.words
