atcoder#TOKIOMARINE2020F. Triangles
Triangles
Score : points
Problem Statement
In a two-dimensional plane, we have a rectangle whose vertices are , , , and , where and are positive integers. Here, find the number of triangles in the plane that satisfy all of the following conditions:
- Each vertex of is a grid point, that is, has integer - and -coordinates.
- and shares no vertex.
- Each vertex of lies on the perimeter of , and all the vertices belong to different sides of .
- contains at most grid points strictly within itself (excluding its perimeter and vertices).
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 3 1
12
For example, the triangle with the vertices , , and contains just one grid point within itself and thus satisfies the condition.
5 4 5
132
100 100 1000
461316