Another alternative explanation.
Mark the leftmost square crossed of each row as ‘r’, and the topmost crossed square of each column with ‘c’. Thus, each square can be marked either ‘r’ or ‘c’ or ‘both r and c’ or ‘neither r nor c’. We’ll examine each case.
For a square to be marked both ‘r’ and ‘c’, the diagonal must pass through the upper left corner of the square.
For square to be marked ‘r’, diagonal should pass through its upper edge.
For square to be marked ‘c’, diagonal must pass through its left edge.
For square to be marked neither ‘r’ nor ‘c’, diagonal must pass through it’s upper as well as left edge, which is not possible. Therefore, no triangles are unmarked.
Now, no. of squares crossed = no. of squares marked ‘r’ + no. of squares marked ‘c’ - no. of squares marked both ‘r’ and ‘c’
Now, no. of r’s = no. of rows (only 1 leftmost crossed square in each row)
no. of c’s = no. of columns (only 1 topmost crossed square in each column)
all rows and columns are crossed by the diagonal.
Therefore, squares crossed = rows + columns - (no. of squares marked both ‘r’ and ‘c’)
Now, only 1 square is marked both ‘r’ and ‘c’ as 199 and 991 are coprime.
Therefore squares crossed = 199 + 991 - 1 = 1189
Look at this video if you want a clearer visual explanation: