VK and NCR https://www.codechef.com/PRWR2018/problems/VKNCR

can anyone plzz exaplin me the solution for the yesterday’s contest thankyou ?

By looking at the equation we can say that if k is less then the value of x will be more (as the number of terms will be more) so for finding the maximum value of k we have to make our x small .
consider x = 0 then on the right side of the equation there will be only one term whose value is 1 independent of the value of n+k so we cannot get 2^n
now consider x = 1 we can get 2^n as
C(n,r) represents r combinations out of n things

      C(n+k,0) + C(n+k,1) = 2^n                    C(n,0) will always be 1
                 C(n+k,1) = 2^n - 1                C(n,1) will always be n
                   n + k  = 2^n - 1         
                       k  = 2^n - 1 - n
first find 2^n % 1000000007 using fast exponentiation
an then substract n+1 from that


thanks for this much details :stuck_out_tongue:

1 Like

thnkss bro :slight_smile: