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.
The only problem with this one (and with the matrix tracing problem) where to find a fast and exact algorithm for large modular binomial coefficients. I suspect that there are many other problems here that requires this. Took me a while to find one, but I realized that I could use Fermat's little theorem to compute the modular division (1000000007 is prime) needed for the binomial coefficient.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
The only problem with this one (and with the matrix tracing problem) where to find a fast and exact algorithm for large modular binomial coefficients. I suspect that there are many other problems here that requires this. Took me a while to find one, but I realized that I could use Fermat's little theorem to compute the modular division (1000000007 is prime) needed for the binomial coefficient.