What is the logic of marbles in medium practice section…how it can be (n-1)C(k-1)??..pls help…thanks
There are many duplicates questions related to question please see this post .
medium level problem - Marbles SIGSEGV error - general - CodeChef Discuss.
Hope this will help.
Thanks .
Just two days back even i was wondering the same… when i found this
and please go through Wikipedia. It contains detailed explanation.
It’ll surely help…!!! ![]()
Reali thanks…this qstion was disturbing me for two days…
You can use the popular Beggar’s method (is usually taught in High Schools).
Distribution of n-k coins to k beggars.
For distribution of r identical coins among n beggars is c(n+r-1,r-1)
Applying the formula you get required the formula
Why is the return value for nCk a double?
sorry about that. But its not working with long long int also
https://www.codechef.com/viewsolution/30681172
do i need to change my logic or a minor change in this code would work?
I mean there are 2 ways.
https://www.codechef.com/viewsolution/30683459
https://www.codechef.com/viewsolution/30683586
Got it. Thanks a lot. 
when we want to select remaining n-k coins from infinite coins then (n-r+1)Cr would be used. In this formula n would be (infinity-k) and r would be (n-k). PLEASE help where am i wrong