|
|
back to boardAccepted simple way how to compute sum of distances After sorting of array of x and y all you need to do is to compute this two double sums sum(i=1)^n sum(j=1)^(i-1) (x_i-x_j) and sum(i=1)^n sum(j=1)^(i-1) (y_i-y_j). After simplifications one can obtain that they equal sum(i=1)^n x_i*(2*i-1-n) and sum(i=1)^n y_i*(2*i-1-n). After computations you divide final sum by C_n^2=n*(n-1)/2 and get required answer. Re: Accepted simple way how to compute sum of distances Can you make your Formulations readable? |
|
|