Distinct Distances
Time limit3sMemory limit512 MB
Choose any point q in the plane and minimize the number of distinct Euclidean distances from q to n given integer points.
- Level
Hard8 of 10
- Topics
- Geometry, Math, Brute force, Combinatorics
- Solved
- No attempts yet
Problem
You are setting up a scavenger hunt in the two-dimensional plane.
You have already chosen distinct points of interest, labeled . Point sits at the integer coordinates .
Now you want to choose one more point for the final location. The coordinates of must be finite, but they do not have to be integers. Point may coincide with one of the points .
To make the final location interesting, you want to minimize how many distinct distances there are from to the chosen points. Formally, choose that minimizes , where
Here is the number of elements of , and is the Euclidean distance between and . is a set, so if two or more of the distances are equal, they count as a single element.
Given the coordinates of the points, find the minimum value of .
Warning: inexact arithmetic may make it difficult to identify distances that are exactly equal.
Input
The first line contains one integer ().
Each of the next lines contains two space-separated integers and (), the coordinates of . The points are pairwise distinct.
Output
Print on a single line the minimum number of distinct distances from to all of the points .
Hint
In the first sample you can take , and every point is at distance 5. In the second sample you can take .