Why my code is working for small numbers only? (BINXOR)

this code is giving WA for second constraints and WA from rest.

That’s not a link to your code :slight_smile:

1 Like

https://www.codechef.com/viewsolution/28412623

1 Like

For division in modular arithmetic you need to compute Modular Inverse and multiply with it:
Bold is the line with error:

	for(int i=0;i<k;i++)
	{
		res*=(n-i);
		**res/=(1+i);**
		res%=1000000007;
	}
	return res%1000000007;
1 Like

Can u explain me how to solve it??

Check out this link nCr % p.