QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#12195. Energy Collection

Statistics

Dongdong has a rectangular plot of land where he has planted a type of energy-collecting plant. These plants can collect energy from sunlight. After the plants have collected energy, Dongdong uses an energy collection machine to gather the energy from all these plants.

Dongdong's plants are planted very neatly, with $n$ columns and $m$ plants in each column. The horizontal and vertical spacing between plants is uniform. Therefore, for each plant, Dongdong can represent its position with coordinates $(x, y)$, where $x$ ranges from $1$ to $n$ (representing the $x$-th column) and $y$ ranges from $1$ to $m$ (representing the $y$-th plant in the $x$-th column).

Because the energy collection machine is large and difficult to move, Dongdong has placed it at a corner, at coordinates $(0, 0)$.

The energy collection machine incurs a certain amount of energy loss during the collection process. If there are $k$ plants on the line segment connecting a plant to the energy collection machine, the energy loss is $2k + 1$. For example, when the energy collection machine collects energy from the plant at $(2, 4)$, there is one plant at $(1, 2)$ on the connecting line segment, resulting in an energy loss of $3$. Note that if there are no plants on the line segment connecting a plant to the energy collection machine, the energy loss is $1$. Now, calculate the total energy loss.

The following is an example of energy collection where $n = 5$ and $m = 4$. There are a total of $20$ plants, and the energy loss generated when the machine collects energy from each plant is marked on it.

In this example, a total energy loss of $36$ is generated.

Input

The input contains a single line with two integers $n$ and $m$.

Output

Output a single integer representing the total energy loss generated.

Constraints

  • For $10\%$ of the data: $1 \le n, m \le 10$;
  • For $50\%$ of the data: $1 \le n, m \le 100$;
  • For $80\%$ of the data: $1 \le n, m \le 1000$;
  • For $90\%$ of the data: $1 \le n, m \le 10,000$;
  • For $100\%$ of the data: $1 \le n, m \le 100,000$.

Examples

Input 1

5 4

Output 1

36

Input 2

3 4

Output 2

20

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.