#K14186. Counting Rectangular Subgrids
Counting Rectangular Subgrids
Counting Rectangular Subgrids
You are given a garden represented as a grid with integer dimensions w (width) and h (height). Your task is to compute the number of different rectangular subgrids (or sections) that can be formed within the garden. Each subgrid must have integer dimensions and its sides must be parallel to the sides of the garden.
The number of subgrids is computed as:
\[ \text{count} = \sum_{i=1}^{w} \sum_{j=1}^{h} (w - i + 1)(h - j + 1) \]
For example, if the input is 2 3
, then the number of rectangular subgrids is 18.
inputFormat
The input consists of two space-separated integers w and h (1 ≤ w, h ≤ 103), which represent the width and height of the garden respectively.
outputFormat
Output a single integer — the number of different rectangular subgrids that can be formed in the garden.
## sample1 1
1