Preparing NOJ

A *lattice point* is an ordered pair (*x*, *y*) where *x* and *y* are both integers. Given the coordinates of the vertices of a triangle (which happen to be lattice points), you are to count the number of lattice points which lie completely inside of the triangle (points on the edges or vertices of the triangle do not count).

The input test file will contain multiple test cases. Each input test case consists of six integers *x*_{1}, *y*_{1}, *x*_{2}, *y*_{2}, *x*_{3}, and *y*_{3}, where (*x*_{1}, *y*_{1}), (*x*_{2}, *y*_{2}), and (*x*_{3}, *y*_{3}) are the coordinates of vertices of the triangle. All triangles in the input will be non-degenerate (will have positive area), and −15000 ≤ *x*_{1}, *y*_{1}, *x*_{2}, *y*_{2}, *x*_{3}, *y*_{3} ≤ 15000. The end-of-file is marked by a test case with *x*_{1} = *y*_{1} = *x*_{2} = *y*_{2} = *x*_{3} = *y*_{3} = 0 and should not be processed.

For each input case, the program should print the number of internal lattice points on a single line.

0 0 1 0 0 1 0 0 5 0 0 5 0 0 0 0 0 0

0 6

Info

Provider POJ

Origin Stanford Local 2004

Code POJ2954

Tags

Submitted 223

Passed 62

AC Rate 27.8%

Date 03/06/2019 16:00:26

Related