| 2021-2022 ICPC, Moscow Subregional |
|---|
| Finished |
Given $$$n$$$ points $$$p_1, p_2, \ldots p_n$$$ in the two-dimensional Euclidean plane, calculate the total pairwise Euclidean distance between them. Simple as that.
Recall that Euclidean distance between two points $$$a = (x_1, y_1)$$$ and $$$b = (x_2, y_2)$$$ is defined as follows:
$$$$$$ \operatorname{dist}(a, b) = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2} $$$$$$
The first line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 500\,000$$$), the number of points.
The $$$i$$$-th of the following $$$n$$$ lines contains a pair of integers $$$x_i$$$, $$$y_i$$$ ($$$-10^6 \leq x_i, y_i \leq 10^6$$$), the coordinates of $$$p_i$$$.
Output the value of $$$\sum\limits_{i \lt j} \operatorname{dist}(p_i, p_j)$$$. Your answer will be considered correct if its relative or absolute error does not exceed $$$10^{-2}$$$.
3 -1 2 2 2 -1 -2
12.0000000000
4 0 0 2 0 0 2 2 2
13.6568542490
In the first sample test the pairwise distances are $$$3$$$, $$$4$$$ and $$$5$$$.
In the second sample test the pairwise distances are $$$2, 2, 2, 2, 2\sqrt{2}, 2\sqrt{2}$$$.
| Name |
|---|


