import Control.Applicative import Text.Printf main = do [sn, sp] <- words <$> getLine let n = (read :: String -> Int) sn p = (read :: String -> Double) sp in print $ solve n p solve :: Int -> Double -> Double solve n p = solve_ 2 [1.0,1.0 ..] where solve_ :: Int -> [Double] -> Double solve_ i (x:xs) | i == n = x | otherwise = (+x) $ solve_ (i+1) $ app (\y->y*(1.0 - p)) (i+1) i xs app :: (Double -> Double) -> Int -> Int -> [Double] -> [Double] app f i m ys@(x:xs) | i > n = ys | otherwise = if i `mod` m == 0 then (f x) : app f (i+1) m xs else x: app f (i+1) m xs