Escape Route
InterviewTime limit1sMemory limit128 MB
Given your position and n-1 planet positions, find the closest planet, print both coordinates, and print the distance rounded to two decimals.
- Level
Easy2 of 10
- Topics
- Brute force, Math, Implementation
- Solved
- No attempts yet
Problem
You are surrounded by Imperial warships and must land on a planet to escape. Your best chance is to reach the planet closest to your current location. Unfortunately, the navigation system has been damaged, so you must write a program that finds the planet nearest to your current position.
The distance between two points and is
Input
The first line contains a positive integer , the number of coordinate pairs. Each of the next lines contains two integers and separated by a space. The first pair is the coordinates of your current location; every pair after it is the coordinates of a planet you can escape to.
Output
Print three lines: the coordinates of your current location, the coordinates of the closest planet, and the distance to that planet rounded to two decimal places. If several planets are equally close, print the one that appears first in the input.