import Control.Applicative import Control.Monad import Data.Array.ST import Data.Array.Unboxed import Text.Printf -- Reference: http://sucrose.hatenablog.com/entry/2014/10/10/235805 numDivisorsTable :: Int -> UArray Int Int numDivisorsTable n = runSTUArray $ do t <- newArray (1, n) 0 forM_ [1 .. n] $ \i -> do forM_ [i, 2 * i .. n] $ \j -> do writeArray t j . (+ 1) =<< readArray t j return t computeProbability :: Double -> Int -> Double computeProbability p n = sum $ map prob [2 .. n] where t = numDivisorsTable n prob i = (1 - p) ** (fromIntegral $ subtract 2 $ t ! i) main :: IO () main = do [n, p] <- words <$> getLine printf "%.12f\n" $ computeProbability (read p) (read n)