#P1548. Counting Squares and Rectangles on a Chessboard
Counting Squares and Rectangles on a Chessboard
Counting Squares and Rectangles on a Chessboard
Given a chessboard of size $$N \times M$$, count the total number of squares and the total number of non-square rectangles on the board.
A square is a rectangle with equal side lengths. The total number of squares in an $$N \times M$$ board can be computed as
and the total number of rectangles is given by
Thus, the number of non-square rectangles is obtained by subtracting the number of squares from the total number of rectangles.
inputFormat
Input consists of two integers $$N$$ and $$M$$ (with $$1 \leq N, M \leq 100$$) separated by a space.
outputFormat
Output two integers separated by a space: the first is the number of squares, and the second is the number of non-square rectangles.
sample
2 3
8 10