#K52512. Count Rectangles in a Grid

    ID: 29326 Type: Default 1000ms 256MiB

Count Rectangles in a Grid

Count Rectangles in a Grid

Given a grid of size n \times m, your task is to compute the total number of rectangles that can be formed in the grid. A rectangle is determined by choosing two distinct horizontal lines and two distinct vertical lines from the grid lines. The number of rectangles can be calculated using the formula:

$$\text{Total Rectangles} = \frac{n(n+1)}{2} \times \frac{m(m+1)}{2} $$

Note: Squares are also counted as rectangles.

inputFormat

The input consists of two space-separated integers n and m, representing the number of rows and columns of the grid, respectively.

outputFormat

Output a single integer representing the total number of rectangles that can be formed in the grid.## sample

2 3
18