We’re preparing your current view and syncing the latest data.
You are given coordinates of two points on a plane. You need to find the number of positions with integer coordinates where the third vertex can be placed such that the resulting triangle meets given problem conditions (usually related to area or side length). The problem involves geometric reasoning and counting lattice points satisfying certain constraints.
The input consists of multiple test cases. Each test case contains coordinates of two points as four integers x1, y1, x2, y2.
For each test case, output the number of possible integer coordinate points for the third vertex satisfying the problem condition.
Coordinates values are integers within a reasonable range (e.g., -10^9 to 10^9). Number of test cases up to 10^4.
Example 1
Input
0 0 1 1
Output
2
Explanation
There are exactly two integer coordinate points that can be the third vertex to form the required triangle with the given two points.