import Control.Applicative ((<$>), (<*>)) import Control.Monad (guard) import Data.List (foldl') import Data.Vector.Unboxed (Vector, (!), (//)) import qualified Data.Vector.Unboxed as V main :: IO () main = solve <$> readLn <*> readLn >>= print solve :: Int -> Int -> Double solve n k = sum $ do ti <- [0 .. 6*n] ji <- [0 .. 6*n] guard $ ti > ji return $ dpt ! ti * dpj ! ji where dpt = foldl' f ((V.replicate (6*n+1) 0) // [(0,1.0)]) ((replicate (n-k) l1) ++ (replicate k l2)) dpj = foldl' f ((V.replicate (6*n+1) 0) // [(0,1.0)]) (replicate n l1) f dp ds = V.accum (+) (V.replicate (6*n+1) 0) $ do (v, p) <- ds i <- [0..6*n] guard $ i >= v return (i, dp ! (i-v) / p) l1 = [(1,6.0),(2,6.0),(3,6.0),(4,6.0),(5,6.0),(6,6.0)] :: [(Int,Double)] l2 = [(4,3.0),(5,3.0),(6,3.0)] :: [(Int,Double)]