What is the logic of marbles in medium practice section…how it can be (n-1)C(k-1)??..pls help…thanks

# marbles logic HELP PLSS

**chandan11111**#2

There are many duplicates questions related to question please see this post .

http://discuss.codechef.com/questions/38041/medium-level-problem-marbles-sigsegv-error.

Hope this will help.

Thanks .

**el_diablo**#3

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…!!!

**rishabhjaini**#5

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