#K6351. Counting Diagonal Intersections

    ID: 31769 Type: Default 1000ms 256MiB

Counting Diagonal Intersections

Counting Diagonal Intersections

In this problem, you are given an (m \times n) grid. Each cell of the grid forms a rectangle with a drawn diagonal. Your task is to determine the number of distinct intersection points where these diagonals intersect. The intersections occur at the overlapping parts of adjacent diagonals and can be computed using the formula: ( (m-1) \times (n-1) ).

For instance, in a 2 (\times) 2 grid, there is exactly one intersection point since ( (2-1) \times (2-1) = 1 ).

inputFormat

Input is provided via standard input (stdin) as a single line containing two space-separated integers (m) and (n). Here, (m) represents the number of rows and (n) represents the number of columns in the grid.

outputFormat

Output a single integer to standard output (stdout) representing the number of distinct intersection points after drawing the diagonals in all cells. The result is computed by the formula: ( (m-1) \times (n-1) ).## sample

2 2
1