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.
My answer seems to be working right for most of the test cases, but got wrong on nearly half of the tests. I cannot think of any reason why that happens. Based on the editorial the calculation should be very straight forward. Can you guys look at the output and give me some hint where I got it wrong?
I calculate nCr mod P directly by cancelling out the small prime factors in the anominator and denominator of N!/(K!*(N-K)!). It's much more efficient than the way proposed by the editorial. But I still cannot get it right.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Ajob Subsequence
You are viewing a single comment's thread. Return to all comments →
My answer seems to be working right for most of the test cases, but got wrong on nearly half of the tests. I cannot think of any reason why that happens. Based on the editorial the calculation should be very straight forward. Can you guys look at the output and give me some hint where I got it wrong?
I calculate nCr mod P directly by cancelling out the small prime factors in the anominator and denominator of N!/(K!*(N-K)!). It's much more efficient than the way proposed by the editorial. But I still cannot get it right.