Pak Chanek has a grid that has $$$N$$$ rows and $$$M$$$ columns. Each row is numbered from $$$1$$$ to $$$N$$$ from top to bottom. Each column is numbered from $$$1$$$ to $$$M$$$ from left to right.
Each tile in the grid contains a number. The numbers are arranged as follows:
A domino is defined as two different tiles in the grid that touch by their sides. A domino is said to be tight if and only if the two numbers in the domino have a difference of exactly $$$1$$$. Count the number of distinct tight dominoes in the grid.
Two dominoes are said to be distinct if and only if there exists at least one tile that is in one domino, but not in the other.
The only line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \leq N, M \leq 10^9$$$) — the number of rows and columns in the grid.
An integer representing the number of distinct tight dominoes in the grid.
3 4
9
2 1
1
The picture below is the grid that Pak Chanek has in the first example.
The picture below is an example of a tight domino in the grid.
Название |
---|