#P1548. Counting Squares and Rectangles on a Chessboard

    ID: 14834 Type: Default 1000ms 256MiB

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

$$\text{Squares} = \sum_{k=1}^{\min(N,M)} (N-k+1)(M-k+1), $$

and the total number of rectangles is given by

Rectangles=N(N+1)M(M+1)4.\text{Rectangles} = \frac{N(N+1)M(M+1)}{4}.

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