• + 0 comments

    haskell without DP

    import Data.List (intercalate)
    
    choose (n, k) =
      let k' = min k (n-k)
        in product [n-k'+1..n] `div` product [1..k'] `mod` 100000007
    
    intpair l = (head z, z !! 1)
      where z = map read $ words l
    
    main = do
      cont <- getContents
      let ls = tail $ lines cont
      putStrLn $ intercalate "\n" $ map (show . choose . intpair) ls