P27029 [AtCoder] Cartesian Coordinate
提高+
题目描述

Problem Description

On the $xy$ plane, there are $N$ lines. The $i$-th line is represented by the line equation $A_ix + B_iy = C_i$. Among these $N$ lines and the $x$-axis and $y$-axis, any two distinct lines intersect at exactly one point.

For all pairs $1 \leq i < j \leq N$, place a car at the intersection point of the $i$-th and $j$-th lines. Even if three or more lines intersect at one point, cars are placed independently for each pair of lines. That is, a point of intersection of $k$ lines will have $k(k-1)/2$ cars placed there.

Since all the cars are very old, each car can only move in a direction parallel to the $x$-axis or $y$-axis.

Takahashi, who wants to hold an exhibition of antique cars, decided to set up one venue on the $xy$ plane. Being a car enthusiast, Takahashi wants to minimize the total distance moved by all cars to the venue to avoid damaging them as much as possible. If such a point is not uniquely determined, Takahashi will set up the venue at the point with the smallest $x$-coordinate among those that satisfy the above condition. If it is still not uniquely determined, he will choose the point with the smallest $y$-coordinate in addition to the previous two conditions.

Determine the coordinates of the point where Takahashi will set up the venue.

Input Format

The input is given from the standard input in the following format:

$N$ $A_1$ $B_1$ $C_1$ : $A_N$ $B_N$ $C_N$

Output Format

Output the $x$-coordinate and $y$-coordinate of the point where Takahashi will set up the venue, in that order, separated by a space. The answer will be judged correct if the absolute or relative error is at most $10^{-9}$.

Sample Input and Output

Sample Input #1

3
1 1 1
2 -1 2
-1 2 2

Sample Output #1

1.000000000000000 1.000000000000000

Sample Input #2

4
1 1 2
1 -1 0
3 -1 -2
1 -3 4

Sample Output #2

-1.000000000000000 -1.000000000000000

Sample Input #3

7
1 7 8
-2 4 9
3 -8 -5
9 2 -14
6 7 5
-8 -9 3
3 8 10

Sample Output #3

-1.722222222222222 1.325000000000000

Notes/Hints

Constraints

  • $2 \leq N \leq 4 \times 10^4$
  • $1 \leq |A_i|, |B_i| \leq 10^4 \ (1 \leq i \leq N)$
  • $0 \leq |C_i| \leq 10^4 \ (1 \leq i \leq N)$
  • No two given lines are parallel
  • All inputs are integers
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 1 1 2 -1 2 -1 2 2
样例输出
1.000000000000000 1.000000000000000