#C11455. Closest Points to Origin
Closest Points to Origin
Closest Points to Origin
You are given a set of 2D points. Your task is to find the point or points that are closest to the origin (0, 0) based on the Euclidean distance. The Euclidean distance (d) for a point ((x, y)) is defined as (d = \sqrt{x^2 + y^2}). If there are multiple points with the same minimum distance, output them in the order they appear in the input.
For example, given the points ((1, 2)), ((-2, -1)), ((3, 4)), and ((2, 1)), the points ((1, 2)), ((-2, -1)), and ((2, 1)) are all at the same minimum distance from the origin, thus all three should be output.
inputFormat
The input is read from standard input (stdin). The first line contains a single integer (N) representing the number of points. Each of the following (N) lines contains two space-separated integers (X) and (Y) that represent the coordinates of a point.
outputFormat
Output to standard output (stdout) the point or points that are closest to the origin. Each point should be printed on a separate line in the format: (X, Y)
If there are multiple points, they should be printed in the order they appear in the input.## sample
4
1 2
-2 -1
3 4
2 1
(1, 2)
(-2, -1)
(2, 1)
</p>