Exercise 1255Combinatorics › Inclusion-exclusionM1Added 4 Nov 2026
Stars and bars with upper bounds
#stars and bars#inclusion-exclusion#counting#compositions
Statement
- How many ordered quadruples of integers satisfy and for every ?
- Prove that the number of non-negative integer solutions of is .
Hint
Subtract from each variable to start at . Count all solutions, then remove those with some variable by inclusion-exclusion.
Show solutionHide solution
Solution
2. (Stars and bars.) Write stars in a row and place bars among them; the bars cut the row into groups of stars whose sizes are with sum , and every solution arises exactly once. A configuration is a sequence of symbols of which are bars: possibilities.
1. Put , so and .
- All non-negative solutions: .
- Let be the set of solutions with . Substituting gives -sum : solutions, for each .
- Two variables : the sum would be with equality: and the other two , giving solution for each of the pairs.
- Three variables would need sum : impossible.
By inclusion-exclusion the answer is
Check. Direct enumeration by computer gives .
Remark. Equivalently, is the coefficient of in .
Lesson. Stars and bars counts unconstrained solutions; upper bounds are handled by inclusion-exclusion on the violations.