• + 0 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.