Aoj F pick Theorem

Source: Internet
Author: User

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.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.