MARBLES codechef explaination...
In our problem we are having N marbles we have to pick K colors. And it is necessary that at least one marble of each color. So now we left with N-K marbles which can be of K colors. Now this problem turns into a problem of counting in how many ways we can distribute N-K marbles into K distinguishable colors, with no constraints. This is a problem of "combinations with repetitions" , also known as the "stars and bars problem" . Lets journalize this whole situation for a while … We can also have an r- combination of n items with repetition. And these two conditions must be fulfilled:- order doesn't matter. we can select the same thing multiple times i.e; repetition is allowed. For example: We can choose 6 marbles where only 3 colors are available. Colors are Blue(B), Red(R) , Yellow(Y). How many different selections can we make? Since order doesn’t matter we ‘ll list all of our selection...