#P10907. [蓝桥杯 2024 国 B] 蚂蚁开会
[蓝桥杯 2024 国 B] 蚂蚁开会
Problem Description
On a 2D plane, there are ants. Each ant has a line segment as its movement range. The two endpoints of the -th ant’s movement range are and . Now the ants plan to set meeting centers at the intersection points of these segments. To save as much budget as possible, they decide to set meeting centers only at intersection points that are lattice points (points with integer coordinates). How many meeting centers need to be set?
Input Format
The input consists of lines.
The first line contains a positive integer .
The next lines each contain integers separated by spaces, representing .
Output Format
Output one line containing one integer, representing the answer.
4
0 0 4 4
0 4 4 0
2 0 0 4
2 1 2 3
2
Hint
Sample Explanation.
Among all segments, there are distinct intersection points: , , and . Among them, there are lattice points: and .
Constraints.
For of the testdata, it is guaranteed that .
For of the testdata, it is guaranteed that and . It is guaranteed that no ant’s movement range degenerates into a point. It is not guaranteed that the number of intersection points between any two segments is finite.
Translated by ChatGPT 5