Pick theorem:
Area of the polygon = points in the polyon + points on the side of the polyon/2-1;
There are gcd (n, m) points on the side of vector a (n, m.
F-electric fence
Time Limit: 1000 ms
Description
In this question, the grid point refers to the point where the horizontal and vertical coordinates are all integers.
John, a farmer, built a triangle grid to hold his cows in prison. It pulls from the origin (0, 0)
A power-on wire connecting points (n, m) (0 <= n <32000,0 <m <32000) and then connecting points (P, 0)
(P> 0) and returns to the origin.
The ox can be placed on each grid point inside the grid without encountering the grid (very slim
Ox ). If a grid point hits the grid, it cannot be placed on it. How many headers are there?
Can a cow be put in the power grid of Farmer John?
Input
Multiple groups of data
Each row in each group contains three integers separated by spaces: n, m, and P ..
Output
Each group has only one output line, which contains an integer representing the number of cows that can be included in a specified grid.
Sample Input
7 5 10
Sample output
20
CodeIf this parameter is left blank, the formula is used only.