Under construction

Still being built. Things may change

King's Keep

Time limit1sMemory limit1024 MB

Summary
Given k points, find the minimum over all points of the average Euclidean distance from that point to the other k-1 points.
Level

Easy2 of 10

Topics
Brute force, Math
Solved
No attempts yet

Problem

King Carl's kingdom contains kk keeps (commonly called castles).

The coordinates of the keeps are known. King Carl is convinced that choosing a central keep as his residence could be convenient.

King Carl considers that the average cost to carry commands from his residence to his other keeps should be small.

Compute the minimal average Euclidean distance from his residence keep to the other keeps if King Carl chooses his residence optimally.

The Euclidean distance between two points is the length of a straight line segment between these points.

Input

The input consists of:

  • One line with an integer kk (2≤k≤10002\leq k\leq 1000), the number of keeps.
  • kk lines, each with two integers xx and yy (∣x∣,∣y∣≤1000|x|, |y| \leq 1000), the coordinates of the keeps.

All keeps are at distinct locations.

Output

Output the minimal possible average distance from the keep chosen as the king's residence to all other keeps.

Your answer should have an absolute or relative error of at most 10−610^{-6}.

Examples2

  1. Example 1

    Input
    3
    0 0
    9 9
    0 9
    
    Expected output
    9
    
  2. Example 2

    Input
    5
    -3 5
    6 8
    1 2
    5 -4
    -7 -9
    
    Expected output
    8.405705684