All the Rectangles
How many axis-aligned rectangles (of any size) does an N×M grid contain?
Input: one line with two integers N and M.
Output: C(N+1, 2) · C(M+1, 2).
Constraints:
- 1 ≤ N, M ≤ 105
Sample Tests
Input 1
2 2
Output 1
9
Input 2
1 1
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.