Average Distance


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++

There are \(N\) points on a two-dimensional plane, labeled \(1 \sim N\). The \(i\)-th point is located at \((x_i, y_i)\), and different labels may share the same coordinates. The distance between points \(i\) and \(j\) is defined as \(\sqrt{(x_i - x_j)^2 + (y_i - y_j)^2}\). Little AA writes down every distinct distance that can appear between any unordered pair of points; if a distance value occurs multiple times, it is written only once. For example, if the three points are \((0, 0)\), \((0, 1)\), and \((1, 0)\), the three pairwise distances are \(1\), \(1\), and \(\sqrt{2}\), so Little AA records only the two numbers \(1\) and \(\sqrt{2}\). Let the \(m\) distinct numbers he writes be \(v_1, v_2, \ldots, v_m\). Your task is to compute \(\frac{\sum_{i=1}^m v_i}{m}\).

Input

The first line contains an integer \(N\) (\(2 \le N \le 10^4\)).

Each of the next \(N\) lines contains two integers \(x_i\) and \(y_i\) (\(0 \le x_i, y_i \le 10^3\)), giving the coordinates of point \(i\).

Output

Output a single real number: the required average, rounded to four digits after the decimal point. Let \(ans\) denote the exact answer. It is guaranteed that rounding \(ans + 10^{-8}\) or \(ans - 10^{-8}\) to four decimal places yields the same value as rounding \(ans\) itself.

Scoring

The subtasks impose the following additional constraints:

  • Subtask \(1\) (30 points): \(N = 2\).
  • Subtask \(2\) (10 points): \(N = 3\).
  • Subtask \(3\) (30 points): \(N \le 500\).
  • Subtask \(4\) (30 points): no additional constraints.

Sample Input 1

2
1 0
4 4

Sample Output 1

5.0000

Sample Input 2

3
0 0
10 10
10 10

Sample Output 2

7.0711