We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Different Ways
Different Ways
Sort by
recency
|
12 Discussions
|
Please Login in order to post a comment
Simple bottom up DP solution in Haskell using arrays:
n,m = map(int,input().split()) a1 = [[0]*m]*n for i in range(n): a1[i] = list(map(int,input().split())) a = numpy.array(a1) s = numpy.sum(a,axis = 0) p = numpy.prod(s) print(p) I'm using this track scirpt with my Neoprene Bags page.
haskell without DP
This might be useful: https://blog.plover.com/math/choose.html
I translated it to Haskell (foldr) and passed all tests.
I used the Extended Euclidean Algorithm to calculate the necessary modular inverses for this problem. Solution is in Haskell.