luogu#P4864. Jerry Loves Lines
Jerry Loves Lines
Background
Jerry really likes drawing straight lines on paper.
Problem Description
Jerry has drawn lines on paper. Each line can be written as . Now Jerry wants to know, for each of the lines that can be written as , what the -coordinate is of the intersection point that ranks -th when counted from bottom to top.
If lines intersect a line at the same point, it is counted as points.
Input Format
The first line contains three positive integers .
The next lines each contain two non-zero integers and , describing one line.
The next lines each contain one integer , representing a query.
Output Format
Output lines. Each line contains one integer, representing the answer.
2 3 1
1 2
2 1
0
1
2
1
3
4
Hint
For of the testdata, .
For of the testdata, , .
All other input numbers are within the int range, and it is guaranteed that .
Friendly reminder: if you are not confident about the constant factor of your solution, please inhale oxygen (use O2 optimization). If you are fully confident, go ahead and do whatever you want.
Translated by ChatGPT 5