import Control.Applicative ((<$>)) import Control.Monad (when, foldM, forM_) import Data.Vector.Unboxed.Mutable (IOVector, STVector) import qualified Data.Vector.Unboxed.Mutable as VM main :: IO () main = do [sn, sp] <- words <$> getLine solve (read sn) (read sp) >>= print solve :: Int -> Double -> IO Double solve n p = do ev <- VM.replicate (n+1) 1.0 :: IO (IOVector Double) forM_ [2 .. n] $ \i -> do forM_ [2*i, 3*i .. n] $ \j -> do x <- VM.read ev j VM.write ev j (x * (1.0 - p)) foldM (\e i -> do x <- VM.read ev i return $ e + x ) 0.0 [2..n]