eolymp
bolt
Try our new interface for solving problems
Problems

The painted points

The painted points

prb297 Given the coordinates of the vertices of a triangle (which happen to be lattice points), you must count the number of lattice points that lie completely inside the triangle (points on the edges or vertices of the triangle do not count).

Input

Each line consists of six integers x1, y1, x2, y2, x3, and y3, where (x1, y1), (x2, y2), and (x3, y3) are the coordinates of triangle vertices. All triangles are non-degenerate (have positive area) and -15000x1, y1, x2, y2, x3, y315000. The last line contains six zeros and should not be processed.

Output

For each input line print the number of internal lattice points in a single line.

Time limit 0.1 seconds
Memory limit 64 MiB
Input example #1
1 1 1 6 6 1
0 0 0 0 0 0
Output example #1
6