P1548 [NOIP 1997 Junior] Chessboard Problem

Background

NOIP 1997 Junior, Problem 1.

Description

Given a chessboard with an $N \times M$ grid $(1≤N≤100,1≤M≤100)$, find how many squares and how many rectangles (excluding squares) it contains. For example, when $N=2, M=3$: ![](https://cdn.luogu.com.cn/upload/image_hosting/kkidop2i.png) The number of squares is $8$: there are $6$ squares of side length $1$ and $2$ squares of side length $2$. The number of rectangles is $10$: Specifically: - There are $4$ rectangles of size $2 \times 1$: ![](https://cdn.luogu.com.cn/upload/image_hosting/vhazon60.png) - There are $3$ rectangles of size $1 \times 2$: ![](https://cdn.luogu.com.cn/upload/image_hosting/jr40fqzv.png) - There are $2$ rectangles of size $3 \times 1$: ![](https://cdn.luogu.com.cn/upload/image_hosting/ja0mx48f.png) - There is $1$ rectangle of size $3 \times 2$: ![](https://cdn.luogu.com.cn/upload/image_hosting/kkidop2i.png)

Input Format

One line with two integers $N,M$.

Output Format

One line with two integers, the number of squares and the number of rectangles.

Explanation/Hint

Translated by ChatGPT 5