z-cross
You are given N (2 <= N <= 50000) lines in a plane. Each line is represented in the form y = a + bx, and you know the values of a and b for each line. Moreover, there is no two parallel lines, so every two line intersect. Your goal is to find the intersection with the minimal x coordinate.
InputThe first line of the standard input will contain only one integer N (1 <= N <= 50000), representing the number of lines. Each of the next N lines will contain two real numbers a and b, representing the coefficients of the coresponding line y = a + bx. The values of a and b will be in the range [-1000000, 1000000]
OutputOn the standard ouput you should print one real number with two decimal point precision. The number should represent the x coordinate of the intersection of two of the given lines with the minimal x coordinate.
IMPORTANT: It is garanteed that all the intersections will have x coordinate in the range [-1000000, 1000000]
IMPORTANT: It is garanteed that all the intersections will have x coordinate in the range [-1000000, 1000000]
Input:
Output:
Explanation:
The lines y = 4 + 5x and y = 8 + 8x intersect at x = -1.333333...
4
1.00 2.00
5.00 10.00
4.00 5.00
8.00 8.00Output:
-1.33Explanation:
The lines y = 4 + 5x and y = 8 + 8x intersect at x = -1.333333...
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.