5. A $20 \times 19$ rectangle is plotted on the Cartesian plane with one corner at the origin and with sides parallel to the coordinate axes. How many unit squares do the two diagonals of this rectangle pass through?
Answer: 74
Solution: Suppose that one corner of the rectangle is on $(20,19)$. First of all, note that 20 and 19 are relatively prime. This means that the line does not intersect any vertex of a unit square in the interior of the grid.
Now, consider the diagonal from $(0,0)$ to $(20,19)$. This diagonal intersects exactly 19 vertical segments and 18 horizontal segments. Here, each intersection point represents an entry point into a new unit square. Including the original unit square (which has the origin as a corner), this accounts for a total of $19+18+1=38$ unit squares.
Similarly, the other diagonal of the rectangle passes through 38 unit squares. Finally, since the diagonals intersect at the center, the center must have been an entry point for one diagonal and an exit point for the other, and vice versa. These pertain to the two unit squares that both diagonals pass through.
Therefore, the diagonals pass through a total of $2(38)-2=74$ unit squares.