Ezvor

2927. Distribute Candies Among Children III

HardMath Preparing judge… LeetCode
MathCombinatorics

Hints

Hint 1
Try to solve the problem using combinatorics.
Hint 2
If the limit didn’t exist, the problem would be distributing n candies between 3 children.
Hint 3
The answer to the above problem would be C(n + 2, 2).
Hint 4
Now try to combine this with the Inclusion-exclusion principle.
Hint 5
Apart from the above solution, there are other mathematical solutions that you can think of.