import Data.Array import Data.Ratio import qualified Data.IntMap as IM import Control.Monad (liftM, forM_) import Text.Printf fact :: Integer -> Integer fact n | n <= 1 = 1 | otherwise = n * fact (n-1) comb :: Integer -> Integer -> Integer comb m n | m < n = 0 comb m n = product [m,m-1..(n+1)] `div` fact (m-n) f :: Integer -> Integer -> Rational f c n = table ! 0 where allc = comb c n table = array (0,c) [(i, g i) | i<-[0..c]] g cur | cur==c = 0 | otherwise = r / (1-r) + x / (1-r) where r = comb cur n % allc x = sum $ do let remain = c - cur new <- [1 .. min n remain] let count = (table ! (cur+new)) + 1 return $ (comb remain new * comb cur (n-new) % allc) * count main :: IO () main = do n <- liftM read getLine forM_ [(1::Int)..n] $ \i -> do [c,n] <- liftM (map read . words) getLine printf "Case #%d: %.7f\n" i (fromRational (f c n) :: Double)