Problem 10.4. Given a rectangular grid of cells. It is known that:

- there are exactly 940 ways to cut out a $1 \times 2$ rectangle from it along the grid lines;
- there are exactly 894 ways to cut out a $1 \times 3$ rectangle from it along the grid lines.

How many ways are there to cut out a $1 \times 5$ rectangle from it along the grid lines?

When counting the number of ways to cut out a rectangle, both vertical and horizontal orientations are considered.
Answer: 802.

Solution. Let the table have $a$ rows and $b$ columns. Without loss of generality, $a \leqslant b$. It is clear that at least one of the numbers $a$ and $b$ is not less than 2.

- Suppose $a=1$. Then from the table $1 \times b$, a rectangle $1 \times 2$ can be cut in $b-1=940$ ways, and a rectangle $1 \times 3$ can be cut in $b-2=894$ ways. Clearly, such values of $b$ do not exist.
- Suppose $b \geqslant a \geqslant 2$. Then from the table $a \times b$, a rectangle $1 \times 2$ can be cut in $a(b-1)+b(a-1)$ ways, and a rectangle $1 \times 3$ can be cut in $a(b-2)+b(a-2)$ ways. Therefore, $a(b-1)+b(a-1)=940$ and $a(b-2)+b(a-2)=894$. Subtracting the second equation from the first, we get $a+b=46$. From this, it follows that $ab=493$. By the converse of Vieta's theorem, the numbers $a$ and $b$ are the roots of the polynomial $x^{2}-46x+493=(x-17)(x-29)$, so $a=17$ and $b=29$. A rectangle $1 \times 5$ can be cut from the table $17 \times 29$ in exactly $17 \cdot 25+13 \cdot 29=802$ ways.