In TCS codevita-2016 round 2 there was a question in which we need to calculate sum of even binomial coefficients like ((nC0)+(nC2)+(nC4)+(nC6)+...+(nCk)) mod 10^9+7 where n and k can be upto 10^14 and k<=n
How do i solve it ?? ( im not sure about the time constraint , It might be greater than the normal 1s)
Go from n to n-1. Now you have all binomial coefficients instead of even ones.
Sorry if this is supposed to be easy but if we convert to n-1, then we need to evaluate the following:
How do you solve this?
Well, looks like calculating even one binomial coefficient (which is difference between 2 sums and so strictly easier problem) is hard. The factorial modulo prime can be calculated in O(n^(0.5+eps)) with FFT. And it requires more than 1000 seconds: http://fredrikj.net/blog/2012/03/factorials-mod-n-and-wilsons-theorem .
You can try to use Lucas theorem to reduce the size of n and k to ~109.