#c221104. 能量采集
能量采集
Energy Harvest
Problem Source
NOI2010
Problem Description
Dongdong has a rectangular piece of land on which he grows an energy plant that can collect solar energy. After the plants collect energy, Dongdong uses an energy collector to gather all the collected energy together.
The plants are planted very neatly: there are columns, each with plants, and the horizontal and vertical spacing between plants is identical. Therefore, for each plant, Dongdong can represent its position with a coordinate , where ranges from to and ranges from to , meaning it is the -th plant in the -th column.
Because the energy collector is large and inconvenient to move, Dongdong places it in a corner, exactly at coordinate .
There is some energy loss while the collector gathers energy. If the line segment connecting a plant to the collector contains other plants, the energy loss is . For example, when the collector gathers the plant at , since there is a plant on the connecting segment, an energy loss of is produced. Note that if there are no other plants on the segment connecting a plant to the collector, the energy loss is . Compute the total energy loss.
Input Format
One line containing two integers ().
Output Format
A single integer: the total energy loss.
Sample Input 1
5 4
Sample Output 1
36
Sample Input 2
3 4
Sample Output 2
20