Triangle
Time limit1sMemory limit128 MB
Count the lattice points strictly inside a lattice triangle given by its three vertices, for many test cases.
- Level
Medium7 of 10
- Topics
- Geometry, Number theory, Math
- Solved
- No attempts yet
Problem
A lattice point is an ordered pair where both and are integers. Given the coordinates of the three vertices of a triangle, all of which are lattice points, count how many lattice points lie strictly inside the triangle. Points that lie on an edge or at a vertex do not count.
Input
The input contains several test cases. Each test case consists of six integers , , , , , , the coordinates of the vertices , , and . Every triangle is non-degenerate (it has positive area), and every coordinate satisfies . The end of the input is marked by a test case with , which must not be processed.
Output
For each test case, print the number of interior lattice points on its own line.