无约束与带约束条件下20红20蓝球分给4名学生的分法求解
Hey there, let's break down these two ball distribution problems step by step:
Since the distribution of red balls and blue balls are independent events, we can calculate their possible ways separately and multiply the results.
As you noted, for 20 identical red balls distributed to 4 distinct students, we use the stars and bars theorem for non-negative integer solutions (students can receive 0 balls). The formula is:
$$\binom{20 + 4 - 1}{4 - 1} = \binom{23}{3}$$
The exact same logic applies to the 20 blue balls—they also have $\binom{23}{3}$ possible distributions.
So the total number of unconstrained ways is the product of the two values:
$$\left(\binom{23}{3}\right)^2$$
If you compute the concrete number, $\binom{23}{3} = 1771$, so the total unconstrained ways are $1771^2 = 3,136,441$.
For this problem, we’ll use the principle of inclusion-exclusion alongside the stars and bars method to account for the strict bounds (each student gets at least 3 and at most 7 of each color). Let’s focus on one color first (red balls)—the calculation for blue balls will be identical.
Step 1: Transform variables to simplify constraints
Let $x_i$ be the number of red balls given to the $i$-th student. We need to solve:
$$x_1 + x_2 + x_3 + x_4 = 20$$
with $3 \leq x_i \leq 7$ for all $i$.
Let $y_i = x_i - 3$ (this shifts the lower bound to 0, making it easier to work with). Now $y_i \geq 0$, and the upper bound becomes $y_i \leq 7 - 3 = 4$. The equation transforms to:
$$y_1 + y_2 + y_3 + y_4 = 20 - 4 \times 3 = 8$$
Now we need the number of non-negative integer solutions to this equation where each $y_i \leq 4$.
Step 2: Apply inclusion-exclusion
Total unconstrained solutions for the transformed equation:
$$\binom{8 + 4 - 1}{4 - 1} = \binom{11}{3} = 165$$Subtract solutions where at least one $y_i \geq 5$:
Pick one student, let $y_i' = y_i - 5$ (so $y_i' \geq 0$). The equation becomes:
$$y_i' + y_1 + ... + y_{i-1} + y_{i+1} + ... + y_4 = 8 - 5 = 3$$
The number of solutions here is $\binom{3 + 4 - 1}{4 - 1} = \binom{6}{3} = 20$. There are 4 students to choose from, so total invalid solutions here are $4 \times 20 = 80$.Add back solutions where at least two $y_i \geq 5$:
If two students had $y_i \geq 5$, their combined minimum would be $5 + 5 = 10$, which is more than 8 (the total we need to distribute). So there are 0 such solutions.
Step 3: Calculate valid solutions for one color
The number of valid red ball distributions is:
$$165 - 80 + 0 = 85$$
Since blue balls have the same constraints and total count, they also have 85 valid distributions.
Total constrained ways
Multiply the two results to get the total number of valid distributions:
$$85 \times 85 = 7225$$
内容的提问来源于stack exchange,提问作者Sulayman

