Average Distance

Points 100 1.0s 256M

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

Problem page help

Keyboard shortcuts

Main features

  • Sample tests — Runs the sample cases bundled with the problem and auto-compares against the expected output.
  • Custom test — Run your code with your own stdin. Optionally tick the "Compare with expected (diff)" box to verify against expected output line-by-line.
  • Template — Paste the default code template you set on your profile page.
  • Collab — Edit this problem together with classmates in real time.
  • Auto-draft — Editor contents auto-save to your browser every 1.5 seconds (per account / problem / language).
  • Submit — Send your code to the judge for grading; returns AC / WA / TLE etc.

Limits

  • Source code: at most 65,536 characters
  • Custom test stdin and expected output: at most 1 MB each (≈1 million characters)
  • Custom test and sample test share the sandbox; about 1 request per 3 s per user (sample test: 1 per 1 s)
  • Custom test and sample test both have a 15 second wall-clock cap (the official judge still uses the problem time limit)
  • Interactive problems do not offer custom test (cannot simulate interaction with the judge).
  • Submitting has no rate limit, but rapid repeated submissions on the same problem are treated as score farming.