Combinatorics - Baffle Method

The object of this kind of question is to put n identical items of the same kind in m different boxes. How many ways are there?

In this question, there are two forms of asking:

1. The box cannot be empty

  Then the answer is C(n-1, m-1)

2, the box can be empty

  Because the premise of the partition method is that the box cannot be empty, in order to meet this condition, we first put a small ball in each box, then the total ball is now m+n, and there are m+n-1 in the middle gap, so the total number of solutions is C(m+n-1, m-1)

 

 

Question 2

There are n different elements, each element can be selected multiple times, a total of k elements are selected, how many options are there? For example, when n = 3, k = 2, there are 6 types, (1, 1)(1, 2)(1, 3)(2, 2)(2, 3)(3, 3)

analyze:

Let the i-th element select xi, then x1 + x2 + ... + xn = k, the problem can be regarded as putting k into n different boxes, the boxes can be empty, ask how many solutions there are in the end, Typical diaphragm method, C(n+k-1, n-1) = C(n+k-1, k)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738372&siteId=291194637