Generating Functions · Generating Functions
Lesson 12
At first glance, it is not so clear how to solve this, but if you look more closely, you will see that the restrictions are chosen specifically, making it not too hard to find the answer. Indeed, let \(k\) be the total number of apples and pears. We will show that this number uniquely determines all four required numbers. If there are \(k\) apples and pears in total, then there will be \(k \bmod 2\) pears and \(k - (k \bmod 2)\) apples. At the same time, there will be \((n-k)\) bananas and oranges in total. Then there will be \((n-k) \bmod 5\) oranges and \((n-k)-((n-k) \bmod 5)\) bananas. Since \(k\) can take values \(0,1,\dotsc,n\), the answer to the problem will be \(n+1\).
Below, we will show how this answer could have been obtained using generating functions.