fork download
  1. import Data.Array
  2.  
  3. memoized_binomial :: Integer -> Integer -> Integer
  4. memoized_binomial a b = arr ! (a, b) where
  5. arr = array ((0, 0), (size, size)) [((x, y), inner (x, y) size) | x <- [0..size], y <- [0..size]]
  6. where inner (x, y) size
  7. | x == 0 && y == 0 = 0
  8. | x == 0 || y == 0 = 1
  9. | otherwise = arr ! (x - 1, y) + arr ! (x, y - 1)
  10. size = max a b
  11.  
  12. main = putStrLn $ show $ memoized_binomial 800 800
Success #stdin #stdout 1.15s 117248KB
stdin
Standard input is empty
stdout
886758324272110719282468686879536361457351622657983619121681971864823233331589221250359432261468147135933370909829053538163845995985088712282515329522750222379031947188666517397254719707323414953335609483867048436232634405323188637876061293480030952312211193078478973979253741391505347189612395970898130251421740603364990257291343139048628543399749402864756324566872108155027609528759946296604108771462220362337026916630726896133207343677015896455480787250090029343572616299975784