Avian Open Round #1 > C. All the Rectangles

All the Rectangles

Difficulty: 1200 2000 ms 128 MB

math combinatorics

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

Read the Editorial

Submit Your Solution

Log in or create a free account to run and submit code.
Ctrl+Enter submit · Ctrl+Space autocomplete · F11 fullscreen