题目描述
Problem Description
Translated from [CERC2018] Mirrority Report
In a physics class, each student is required to complete a midterm project. You chose to conduct an experiment to investigate the properties of a rare unstable particle known as the Red Particle. A Red Particle always propagates in a straight line until it is reflected by a mirror.
Our experiment consists of several single-use mirrors, which can be considered as infinite straight lines on a two-dimensional plane. A single-use mirror will reflect the particle only the first time it arrives, regardless of the direction of incidence, but after that, the particle will simply pass through the mirror.
Reflection follows the law of reflection. If the particle reaches the intersection point of two mirrors, it will disintegrate; otherwise, it will be reflected.
The arrangement of the mirrors is set by your lab instructor, and your task is to determine how many different initial directions from a starting point will cause the particle to reach a specific point.
Input Format
The first line contains a non-negative integer $N$, representing the number of mirrors.
The second line contains four integers $S_x, S_y, E_x, E_y$, indicating that the particle starts at $(S_x, S_y)$ and the destination is $(E_x, E_y)$.
The next $N$ lines, each containing four integers $A_x, A_y, B_x, B_y$, represent two points on the $i$-th mirror.
All coordinate values in the input are within $[-100, 100]$. The starting and ending points are different. The distance from the starting or ending point to any mirror is non-zero.
It is guaranteed that there is no valid scenario where the distance between the incident point on any mirror that can reflect the particle and the intersection of two mirrors is less than $10^{-4}$.
Output Format
Output a single integer on one line, representing how many different initial directions from $(S_x, S_y)$ will cause the particle to reach $(E_x, E_y)$.
Sample Input and Output
Sample Input #1
2
2 3 4 2
2 2 3 3
1 4 3 4
Sample Output #1
1
Sample Input #2
3
2 3 5 2
1 3 1 1
2 4 4 2
5 4 6 5
Sample Output #2
1
Sample Input #3
1
0 0 4 0
0 4 4 4
Sample Output #3
2
Notes
The diagrams for the samples are provided in the original problem statement.
$0 \leq N \leq 8$
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分