#K54512. Count Rectangles in a Grid
Count Rectangles in a Grid
Count Rectangles in a Grid
Given an m x n grid, your task is to compute the total number of distinct rectangles that can be formed within the grid. A rectangle is defined by choosing two different horizontal boundaries and two different vertical boundaries. The total number of rectangles can be computed by the formula
[ \frac{m(m+1)n(n+1)}{4} ]
For example, in a 2 x 3 grid, the number of rectangles is 18.
inputFormat
Input is read from standard input. It consists of two space-separated integers, m (the number of rows) and n (the number of columns) of the grid.
outputFormat
Output the total number of distinct rectangles that can be formed in an m x n grid to standard output.## sample
2 3
18