How many rectangles can be seen on the chessboard? Among these, how many are squares?
If we extend the vertical sides of a rectangle, we get a vertical strip on the chessboard. Similarly, the horizontal sides define a horizontal strip. Conversely, if we specify a vertical strip and a horizontal strip on the chessboard, bounded by lines separating the chessboard squares, they uniquely determine a rectangle (Figure 7).

![](https://cdn.mathpix.com/cropped/2024_05_02_5446f37b0a8666ac312eg-1.jpg?height=428&width=425&top_left_y=336&top_left_x=839)

Figure 7

Thus, the number of all rectangles is the product of the number of vertical and horizontal strips.

It is clear that the number of vertical and horizontal strips is the same, so it is sufficient to count, for example, the former. The squares of the chessboard are bounded by 9 vertical lines.

We can choose the first boundary line in 9 ways, and the second from the remaining in 8 ways. However, this way we count each strip twice, so the number of vertical strips is

$$
\frac{9 \cdot 8}{2}=36
$$

The number of horizontal strips is the same, so the total number of rectangles is

$$
36^{2}=1296
$$

Among these, there are as many squares as there are ways to pair vertical and horizontal strips of the same width.

A vertical strip of width $h$ cannot have its left boundary on any of the last $h$ vertical lines, so the number of strips of width $h$ is $9-h$, and the same is true for the horizontal ones, so there are $(9-h)^{2}$ squares of width $h$. Therefore, the number of squares is (for $h=1,2, \ldots, 8$) $8^{2}+7^{2}+6^{2}+5^{2}+4^{2}+3^{2}+2^{2}+1^{2}=204$.