P25486 [AtCoder] [ABC022D] Big Bang
提高-
题目描述

Problem Description

It is known that the universe has been expanding continuously since its birth due to the Big Bang.

Takahashi, an astronomer, decided to measure the speed of this cosmic expansion.

Takahashi observed the positions of the same $N$ stars on two different days. The positions of the stars are recorded as points on a coordinate plane. Thus, each observation result consists of a set of $N$ points on the coordinate plane.

Comparing the results of the two observations, he found that the set of points from the first observation can be transformed into the set of points from the second observation by performing the following three operations in sequence:

  1. Translate by the same distance in the same direction.
  2. Rotate around the origin by the same angle.
  3. Magnify by a factor of $P$ ($1 \leq P$) around the origin. That is, transform the point $(a, b)$ to the point $(a \times P, b \times P)$ for all points.

Here, if the value of $P$ is known, it seems possible to determine the expansion speed.

However, Takahashi, in his attempt to determine $P$, accidentally lost the data that recorded which point corresponds to which star.

Therefore, Takahashi decided to seek help from you, an excellent programmer.

Given the results of the first and second observations, find the value of $P$.

Input Format

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

$N$ $Ax_1$ $Ay_1$ $Ax_2$ $Ay_2$ : $Ax_N$ $Ay_N$ $Bx_1$ $By_1$ $Bx_2$ $By_2$ : $Bx_N$ $By_N$

  • The first line contains the number of stars $N$ ($2 \leq N \leq 10^5$) observed by Takahashi.
  • The next $N$ lines contain the $x$ and $y$ coordinates of the $i$-th star observed in the first observation as two integers $Ax_i, Ay_i$ ($-15,000 \leq Ax_i, Ay_i \leq 15,000$), separated by a space.
  • The following $N$ lines contain the $x$ and $y$ coordinates of the $i$-th star observed in the second observation as two integers $Bx_i, By_i$ ($-10^9 \leq Bx_i, By_i \leq 10^9$), separated by a space.
  • Neither the first nor the second observation has multiple stars observed at the same point.
  • The $i$-th star observed in the first observation is not necessarily the same star as the $i$-th star observed in the second observation.

Output Format

Output the value of $P$ in one line. The output is accepted if the absolute or relative error is at most $10^{-6}$. Include a newline at the end of the output.

Sample Input and Output

Sample Input #1

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

Sample Output #1

2.8284271247

Sample Input #2

6
3 4
1 3
4 3
2 2
0 1
2 0
5 5
-1 2
-1 -3
2 1
2 6
4 -3

Sample Output #2

2.2360679775

Notes/Hints

Partial Points

This problem has partial points.

  • If you correctly solve the dataset where $1 \leq N \leq 3,000$, you will be awarded 50 points.
  • If you correctly solve the dataset where $1 \leq N \leq 10^5$, you will be awarded an additional 50 points. The total is 100 points.

Sample Explanation 1

The set of points from the first observation can be transformed into the set of points from the second observation by performing the following operations:

  1. Translate by $-0.5$ in the $x$ direction and $-0.5$ in the $y$ direction.
  2. Rotate $45^\circ$ clockwise around the origin.
  3. Magnify by a factor of $2\sqrt{2}$ around the origin.

Thus, $P = 2\sqrt{2}$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 0 0 0 1 1 0 1 1 0 2 2 0 -2 0 0 -2
样例输出
2.8284271247