#P1447. [NOI2010] 能量采集

    ID: 440 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学2010NOI 系列最大公约数,gcd莫比乌斯反演

[NOI2010] 能量采集

Description

Dongdong has a rectangular field where he planted an energy plant that can harvest energy from sunlight. After these plants harvest energy, Dongdong uses an energy aggregation machine to gather all the energy collected by the plants.

Dongdong planted the plants in a very neat grid: there are nn columns, and each column has mm plants, with equal spacing both horizontally and vertically. Therefore, for each plant, Dongdong can denote it by a coordinate (x,y)(x, y), where xx ranges from 11 to nn and yy ranges from 11 to mm, meaning it is the yy-th plant in column xx.

Because the energy aggregation machine is large and not easy to move, Dongdong placed it at a corner, exactly at the coordinate (0,0)(0, 0).

There is some energy loss during the aggregation process. If the line segment connecting a plant and the energy aggregation machine contains kk plants, then the energy loss is 2k+12k + 1. For example, when the machine collects energy from the plant at (2,4)(2, 4), since there is a plant at (1,2)(1, 2) on the connecting segment, the loss is 33. Note that if there are no plants on the line segment connecting the plant and the machine, then the energy loss is 11. Now compute the total energy loss.

Below is an example of energy collection with n=5n = 5 and m=4m = 4, for a total of 2020 plants. Each plant is labeled with the energy loss incurred when the machine collects its energy.

In this example, the total energy loss is 3636.

Input Format

One line with two integers n,mn, m.

Output Format

Output a single integer representing the total energy loss.

5 4

36

3 4
20

Hint

  • For 10% of the testdata: n,m10n, m \le 10.
  • For 50% of the testdata: n,m100n, m \le 100.
  • For 80% of the testdata: n,m103n, m \le 10^3.
  • For 90% of the testdata: n,m104n, m \le 10^4.
  • For 100% of the testdata: 1n,m1051 \le n, m \le 10^5.

Translated by ChatGPT 5