#C13684. Find the Nearest Point

    ID: 43249 Type: Default 1000ms 256MiB

Find the Nearest Point

Find the Nearest Point

Given a list of points in multi-dimensional space and a reference point, your task is to find the nearest point to the reference point and compute the Euclidean distance between them. The Euclidean distance between two points (\mathbf{p}= (p_1, p_2, \ldots, p_n)) and (\mathbf{q}= (q_1, q_2, \ldots, q_n)) is defined as (\sqrt{\sum_{i=1}^{n}(p_i-q_i)^2}).

Note: All coordinates are given as real numbers.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  1. The first line contains an integer (N) representing the number of points.
  2. The next (N) lines each contain space-separated real numbers representing the coordinates of a point.
  3. The last line contains the space-separated coordinates of the reference point.

All points, including the reference point, have the same number of dimensions.

outputFormat

Print the result to standard output (stdout) in two lines:

  1. The first line should list the coordinates of the nearest point (space-separated).
  2. The second line should contain the Euclidean distance from the reference point to the nearest point, formatted to 6 decimal places.## sample
3
1 2
3 4
-1 -1
0 0
-1 -1

1.414214

</p>