Problem:
 Score : 300 points    Problem Statement There are N towns in a coordinate plane. Town i is located at coordinates ( x_i , y_i ). The distance between Town i and Town j is \sqrt{\left(x_i-x_j\right)^2+\left(y_i-y_j\right)^2} .  There are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \dots , towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.      Constraints  2 \leq N \leq 8  -1000 \leq x_i \leq 1000  -1000 \leq y_i \leq 1000  \left(x_i, y_i\right) \neq \left(x_j, y_j\right) (if i \neq j )  (Added 21:12 JST) All values in input are integers.         Input Input is given from Standard Input in the following format:  N  x_1  y_1  :  x_N  y_N       Output Print the average length of the paths.
Your output will be judges as correct when the absolute difference from the judge's output is at most 10^{-6} .        Sample Input 1 3
0 0
1 0
0 1      Sample Output 1 2.2761423749  There are six paths to visit the towns: 1 → 2 → 3 , 1 → 3 → 2 , 2 → 1 → 3 , 2 → 3 → 1 , 3 → 1 → 2 , and 3 → 2 → 1 .  The length of the path 1 → 2 → 3 is \sqrt{\left(0-1\right)^2+\left(0-0\right)^2} + \sqrt{\left(1-0\right)^2+\left(0-1\right)^2} = 1+\sqrt{2} .  By calculating the lengths of the other paths in this way, we see that the average length of all routes is:  \frac{\left(1+\sqrt{2}\right)+\left(1+\sqrt{2}\right)+\left(2\right)+\left(1+\sqrt{2}\right)+\left(2\right)+\left(1+\sqrt{2}\right)}{6} = 2.276142...       Sample Input 2 2
-879 981
-866 890      Sample Output 2 91.9238815543  There are two paths to visit the towns: 1 → 2 and 2 → 1 . These paths have the same length.       Sample Input 3 8
-406 10
512 859
494 362
-955 -475
128 553
-986 -885
763 77
449 310      Sample Output 3 7641.9817824387

Solution (Python):
n = int(input())
xy = []

for _ in range(n):
    x, y = map(int, input().split())
    xy.append([x, y])

dist = 0

for i in range(n):
    for j in range(n):
        dist += (((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5)/n

print(dist)

Solution (Python):
n = int(input())
xy = []

for _ in range(n):
    x, y = map(int, input().split())
    xy.append([x, y])

dist = 0

for i in range(n):
    for j in range(n):
        if i != j:
            dist += (((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5)/n

print(dist)

Solution (Python):
n = int(input())
xy = []

for _ in range(n):
    xy.append(input().split())

dist = 0

for i in range(n):
    for j in range(n):
        if i != j:
            dist += (((int(xy[i][0]) - int(xy[j][0]))**2 + (int(xy[i][1]) - int(xy[j][1]))**2)**0.5)/n

print(dist)

Solution (Python):
from itertools import permutations
from math import sqrt,factorial
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

def distance(point1, point2):
    return sqrt((point1[0]-point2[0])**2 + (point1[1]-point2[1])**2)

ans = 0
per = permutations(xy, n)
persize = factorial(n)
cost = 0
for i in per:
    cpoint = i[0]
    for j in i[1:]:
        cost += distance(cpoint, j)
        cpoint = j
ans = cost/persize
print(ans)

Solution (Python):
import math
from itertools import permutations

n = int(input())
l = []
for i in range(n):
    x, y = map(int, input().split())
    l.append([x, y])

ans = []
for i in permutations(range(n)):
    temp = 0
    for j in range(n-1):
        temp += math.sqrt((l[i[j+1]][0] - l[i[j]][0])**2 + (l[i[j+1]][1] - l[i[j]][1])**2)
    ans.append(temp)

print(sum(ans)/len(ans))

Solution (Python):
import math
import itertools
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())
 
l = list(itertools.permutations(range(n)))
length = []
for perm in l:
    length.append(sum([math.sqrt((x[perm[i]]-x[perm[i+1]])**2+(y[perm[i]]-y[perm[i+1]])**2) for i in range(n-1)]))
 
print(sum(length)/math.factorial(n))

Solution (Python):
def permutation(index, n): 
  if index == 1:
    new_box = []
    for i in range(n):
      new_box.append([i])
    return new_box
  
  curr_box = permutation(index - 1, n)
  new_box = []
  for fact_list in curr_box:
    for i in range(n):
      if i in fact_list:
        continue
      new_box.append(fact_list + [i])
  return new_box

def distance(p1, p2, xy):
  return ((xy[p1][0] - xy[p2][0]) ** 2 + (xy[p1][1] - xy[p2][1]) ** 2) ** (1 / 2)

n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]
per = permutation(n, n)
nway = len(per)
sum_dist = 0
for l in per:
  for i in range(len(l) - 1):
    sum_dist += distance(l[i], l[i + 1], xy)
print(sum_dist / nway)

Solution (Python):
import math
import itertools
from functools import lru_cache

N = int(input())

x = [0]*N
y = [0]*N
d = []

@lru_cache(maxsize=1000)
def calc(x1,y1,x2,y2):
        d1 = int((int(x2) - int(x1))** 2)
        d2 = int((int(y2) - int(y1))** 2)
        distance = d1 + d2
        return(math.sqrt(distance))

for i in range(N):
    x[i], y[i] = input().split(' ')

a = list(itertools.permutations(range(N)))


for i in range(len(a)):
    b = a[i]
    for j in range(len(b)-1):
            ans = calc(x[b[j]],y[b[j]],x[b[j+1]],y[b[j+1]])
            d.append(ans)

print(sum(d)/len(a))

Solution (Python):
import math
import itertools
N= int(input())
zahyou=[list(map(int,input().split())) for i in range(N)]
lis = [i for i in range(N)]
permutations_lis=itertools.permutations(lis)
goukei=0
for i in permutations_lis:
    for j in range(N-1):
        goukei += math.sqrt(pow((zahyou[i[j+1]][0]-zahyou[i[j]][0]),2)+pow((zahyou[i[j+1]][1]-zahyou[i[j]][1]),2))
print(goukei/math.factorial(N))

Solution (Python):
import itertools, math
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
orders = list(itertools.permutations(L))
d = 0
for order in orders:
    dist = 0
    for i in range(0,N-1):
        dist += math.sqrt((order[i][0]-order[i+1][0])**2 + (order[i][1]-order[i+1][1])**2)
    d += dist
print(d/len(orders))

Solution (Python):
N=int(input())
P=[]
for i in range(N):
	P.append(list(map(int,input().split())))
D=0
for i in range(N-1):
	for j in range(i+1,N):
		D+=(((P[i][0]-P[j][0])**2+(P[i][1]-P[j][1])**2)**(1/2))
print((D*2/N))

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools








N = int(input())
ans = 0
xy = [list(map(int, input().split())) for _ in range(N)]
l = [int(x) for x in range(N)]
dist = 0
p = list(itertools.permutations(l, N))

for i in range(math.factorial(N)):
  for j in range(N-1):
    dist += math.sqrt((xy[p[i][j]][0]-xy[p[i][j+1]][0])**2+(xy[p[i][j]][1]-xy[p[i][j+1]][1])**2)
  ans += dist
  dist = 0

print(ans/math.factorial(N))

Solution (Python):
import numpy as np
n = int(input())

x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

cnt = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        cnt += np.sqrt((x[i] - x[j]) ** 2 + (y[i] - y [j]) ** 2)
        
ans = cnt * 2 / n

print(ans)

Solution (Python):
import math
import itertools
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

l = list(itertools.permutations(range(n)))
length = []
for perm in l:
    length.append(sum([math.sqrt((x[perm[i]]-x[perm[i+1]])**2+(y[perm[i]]-y[perm[i+1]])**2) for i in range(n-1)]))

print(sum(length)/math.factorial(n))

Solution (Python):
from itertools import permutations
from math import sqrt

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

ans = 0
cnt = 0
base = list(range(0, N))
for order in permutations(base, N):
    cnt += 1
    for i in range(0, N - 1):
        n1 = order[i]
        n2 = order[i + 1]
        res = (XY[n1][0] - XY[n2][0]) ** 2
        res += (XY[n1][1] - XY[n2][1]) ** 2
        ans += sqrt(res)

print(ans / cnt)

Solution (Python):
from itertools import permutations as p
n, *d = map(int, open(0).read().split())
h = []
k = 0
for i in list(p(range(n))):
    for j in range(n - 1): 
        k += ((d[i[j] * 2] - d[i[j+1] * 2])**2 + (d[i[j] * 2 + 1] - d[i[j+1] * 2 + 1])**2)**.5
    h += [k]
    k = 0
print(sum(h) / len(h))

Solution (Python):
import itertools

N = int(input())
lis = [x for x in range(N)]
pos = [list(map(int, input().split())) for _ in range(N)]
dis = []

for p in itertools.permutations(lis):
  dise = 0
  for i in range(N-1):
    
    dise += ((pos[p[i]][0]-pos[p[i+1]][0])**2+(pos[p[i]][1]-pos[p[i+1]][1])**2)**0.5
  dis.append(dise)

print(sum(dis)/len(dis))

Solution (Python):
n=int(input())
t=[]
for i in range(n):
    x,y=map(int,input().split())
    t.append([x,y])
sum=0
for p in range(n-1):
    for q in range(p,n):
        l=(t[p][0]-t[q][0])**2+(t[p][1]-t[q][1])**2
        sum+=l**(1/2)
print((2*sum)/n)

Solution (Python):
import itertools as it
import math

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

path = 0
p = it.permutations(xy)
for r in p:
    for i in range(N - 1):
        path += math.sqrt((r[i][0] - r[i + 1][0])**2 +
                          (r[i][1] - r[i + 1][1])**2)

res = path / math.factorial(N)
print(res)

Solution (Python):
import math
import itertools

N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
P_num = math.factorial(N)
P = itertools.permutations(A)
ans = 0

for l in P:
    for i in range(N-1):
        ans += pow(pow(l[i+1][0]-l[i][0],2)+pow(l[i+1][1]-l[i][1],2),0.5)
print(ans/P_num)

Solution (Python):
import itertools
import math
n = int(input())
points = []
for i in range(n):
    point = list(map(int,input().split()))
    points.append(point)
length = 0
for root in itertools.permutations(points):
    
    for i in range(n-1):
        lengthi = math.sqrt((root[i][0]-root[i+1][0])**2+(root[i][1]-root[i+1][1])**2)
        
        length += lengthi
    



print(length/(math.factorial(n)))

Solution (Python):
from itertools import*
n=int(input())

points=[list(map(int,input().split()))for i in range(n)]

x=list(permutations(points))
y=0
for i in x:
    pre=i[0]
    for j in i[1:]:
        y+=((pre[0]-j[0])**2+(pre[1]-j[1])**2)**0.5
        pre=j
print(y/len(x))

Solution (Python):
from sys import stdin
input = stdin.readline
import math

def main():
    N = int(input())
    p = [list(map(int, input().split())) for _ in range(N)]
    s = 0.0
    for i in range(N - 1):
        for j in range(i + 1, N):
            s += math.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)
    print(s*2/N)

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin

import math

def main():
    N = int(input())
    p = [list(map(int, input().split())) for _ in range(N)]
    s = 0.0
    for i in range(N - 1):
        for j in range(i + 1, N):
            s += math.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)
    print(s*2/N)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import itertools
N = int(input())
p = [list(map(int,input().split())) for _ in range(N)]
print(sum(np.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2) for i, j in itertools.combinations(range(N), 2)) * np.math.factorial(N - 1) * 2 / np.math.factorial(N))

Solution (Python):
import math
N=int(input())
cord=[]
mylist=[]
answer=0
for i in range(N):
    cord=list(map(int,input().split()))
    mylist.append(cord)
    
    



def distance(a,b):
    l=math.sqrt((mylist[a][0]-mylist[b][0])**2+(mylist[a][1]-mylist[b][1])**2)
    return l

for i in range(N-1):
    for j in range(i+1,N):
        
        answer+=distance(i,j)
        
        
print(answer*2/N)

Solution (Python):
import math
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
cd = []
for i in range(n):
    cd.append(iil())

dist = 0
for i in range(n):
    for j in range(i,n):
        dist += math.factorial(n-1)*2*((cd[i][0]-cd[j][0])**2+(cd[i][1]-cd[j][1])**2)**0.5
print(dist/math.factorial(n))

Solution (Python):
import sys
from math import sqrt
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A =[[int(_) for _ in input().split()] for i in range(n)]
    ans=0
    for i in range(n-1):
        for j in range(i+1,n):
            ans+=sqrt((A[i][0]-A[j][0])**2+(A[i][1]-A[j][1])**2)
    print(ans*2/n)
if __name__=='__main__':
    main()

Solution (Python):
import sys
from math import sqrt
from itertools import permutations
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A =[[int(_) for _ in input().split()] for i in range(n)]
    a_list=list(permutations(A))
    a_len=len(a_list)
    ans_all=0
    for i in range(a_len):
        keiro = a_list[i]
        ans=0
        x0=keiro[0][0]
        y0=keiro[0][1]
        for x1,y1 in keiro[1:]:
            ans+=sqrt((x1-x0)**2+(y1-y0)**2)
        ans_all+=ans
    print(ans_all/a_len)
if __name__=='__main__':
    main()

Solution (Python):
from math import sqrt
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

ans = 0
for i in range(N):
  for j in range(N):
    if j != i:
      ans += sqrt((xy[i][0] - xy[j][0]) ** 2  + (xy[i][1] - xy[j][1]) ** 2)
print(ans/N)

Solution (Python):
from math import sqrt

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((xy[i][0] - xy[j][0]) * (xy[i][0] - xy[j][0]) + (xy[i][1] - xy[j][1]) * (xy[i][1] - xy[j][1]))
print(result / N)

Solution (Python):
from math import sqrt, factorial
N = int(input())
x_y = {}
for i in range(N):
    x, y = map(int, input().split())
    x_y[i] = (x, y)

c = 0
d = 0
for i in range(N):
    _d = 0
    for j in range(N):
        if i != j:
            _x = (x_y[i][0] - x_y[j][0]) ** 2
            _y = (x_y[i][1] - x_y[j][1]) ** 2
            d += sqrt(_x + _y)
            c += 1

print(d * (N-1)/c)

Solution (Python):
import math
n = int(input())
dist = [[0]*n for _ in range(n)]
pos = [tuple(map(int, input().split())) for _ in range(n)]
for i in range(n):
    for j in range(n):
        dist[i][j] = ((pos[i][0] - pos[j][0])**2 + (pos[i][1] - pos[j][1])**2)**0.5
from itertools import permutations
per = list(permutations([k for k in range(n)]))
count = 0
for pe in per:
    for l in range(n-1):
        count += dist[pe[l]][pe[l+1]]
ans = count/math.factorial(n)
print(ans)

Solution (Python):
n = int(input())
town = []
for i in range(n):
    town.append([int(i) for i in input().split()])
distance = 0
for i in range(n):
    for j in range(i + 1, n):
        distance += ((town[i][0] - town[j][0])**2 + (town[i][1] - town[j][1])**2)**0.5
distance *= (2 / n)
print(distance)

Solution (Python):
import math

N=int(input())
X=[]
Y=[]
for n in range(N):
    x,y=map(int,input().strip().split())
    X.append(x)
    Y.append(y)

def f(n):
    if n==2:
        return [[1,2],[2,1]]
    else:
        new=[]
        l=f(n-1)
        for e in l:
            base=tuple(e)
            for m in range(len(e)+1):
                e=list(base)
                e.insert(m,n)
                new.append(e)
    return new

l=f(N)
a=[]
for e in l:
    total=0
    for n in range(len(e)-1):
        d=math.sqrt((X[e[n]-1]-X[e[n+1]-1])**2+(Y[e[n]-1]-Y[e[n+1]-1])**2)
        total+=d
    a.append(total)
ave=sum(a)/len(a)

print(ave)

Solution (Python):
N = int(input())
x,y = [],[]
for i in range(N):
    X,Y = [float(e) for e in input().split()]
    x.append(X)
    y.append(Y)

import itertools

ans = []
for order in itertools.permutations([i for i in range(N)]):
    r = 0.0
    for i in range(1,N):
        r += ((x[order[i]]-x[order[i-1]])**2 + (y[order[i]]-y[order[i-1]])**2) ** 0.5
    ans.append(r)

import numpy as np
print(np.mean(ans))

Solution (Python):

N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]

def dist(c,d):
    return ((c[0] - d[0])**2 + (c[1] - d[1])**2)**(1/2)

s = 0
for i in range(N):
    for j in range(i+1,N):
        s += dist(A[i],A[j])

print(2*s/N)

Solution (Python):
import itertools

n = int(input())
pos = []
for _ in range(n):
	x, y = map(int, input().split())
	pos.append([x, y])

def dist(lst):
	d = 0
	for i in range(n-1):
		lst1 = lst[i]
		lst2 = lst[i+1]
		d += ((lst1[0]-lst2[0])**2 + (lst1[1]-lst2[1])**2)**0.5
	return d

d = 0
p_lst = list(itertools.permutations(pos, n))

for v in p_lst:
	d += dist(v)
    
print(d / len(p_lst))

Solution (Python):
n=int(input())
XY=[]
for i in range(n):
    x,y=map(int,input().split())
    XY.append((x,y))
from itertools import permutations
perm=permutations(XY)

dists=[]
for i in perm:
    dist=0
    for j in range(1,n):
        dist+=((i[j][0]-i[j-1][0])**2+(i[j][1]-i[j-1][1])**2)**0.5
    dists.append(dist)
ans=sum(dists)/len(dists)
print(ans)

Solution (Python):
import numpy as np
import math

def d(a, b):
  return np.sum((a - b)**2)**0.5
  
N = int(input())

xy = np.array([list(map(int, input().split())) for _ in range(N)])

a = sum([[d(xy[i], xy[j]) for j in range(i+1, N)] for i in range(0, N)], [])

print(2*sum(a)/N)

Solution (Python):
import math
import itertools
n = int(input())
lista = []
anslist = 0
for i in range(n):
    x, y = map(int, input().split())
    lista.append([x, y])


for i in itertools.permutations(lista):
    for j in range(n - 1):
        anslist += math.sqrt((i[j + 1][0] - i[j][0]) ** 2 + (i[j + 1][1] - i[j][1]) ** 2)
        
            
            

print(anslist / math.factorial(n))

Solution (Python):
import itertools
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
r,c = 0,0
for i in itertools.permutations(a):
    for j in range(n-1):
        r += ((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2)**0.5
    c += 1
print(r/c)

Solution (Python):
N = int(input())
x = []
for i in range(N):
  xi, yi = map(int, input().split())
  x.append((xi,yi))
  
sum_dist = 0
for i in range(len(x) - 1):
  for j in range(i+1, len(x), 1):
    sum_dist += ((x[i][0]-x[j][0])**2 + (x[i][1]-x[j][1])**2)**0.5
print(sum_dist*2/N)

Solution (Python):
from math import hypot

N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]

_sum = 0
for xi, yi in XY:
    for xj, yj in XY:
        _sum += hypot(xi-xj, yi-yj)

print(_sum/N)

Solution (Python):


from itertools import permutations
import math


N = int(input())
point_list = []
for i in range(N):
    x, y = map(int, input().split())
    point_list.append([x, y])


pattern_list = []
moto = [i for i in range(1, N+1)]
distance = 0
patterns = list(permutations(moto))


for p in patterns:
    for i in range(len(p)-1):
        point_1 = point_list[p[i]-1]
        point_2 = point_list[p[i+1]-1]
        tmp = math.sqrt((point_1[0]-point_2[0])**2 + (point_1[1]-point_2[1])**2)
        distance += tmp
distance = distance / len(patterns)


print(distance)

Solution (Python):
from math import factorial, sqrt

def dist(x1, y1, x2, y2):
    return sqrt((x1 - x2)**2 + (y1 - y2)**2)


N = int(input())
x, y = [0]*N, [0]*N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
count = (N-1) * factorial(N) / (N * (N-1) / 2)

for i in range(N-1):
    for j in range(i+1, N):
        ans += dist(x[i], y[i], x[j], y[j]) * count

ans = ans / factorial(N)

print(ans)

Solution (Python):
import math

N = int(input())
XY = []
for _ in range(N):
    xy = list(map(int, input().split()))
    XY.append(xy)

ans = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        ans += math.sqrt(((XY[i][0]-XY[j][0])**2)+((XY[i][1]-XY[j][1])**2))

print(ans/N)

Solution (Python):
n  =int(input())
ls = []
for  i in range(n):
    x,y  =map(int,input().split())
    ls.append((x,y))
import itertools
ans = 0
cnt = 0
a = [i for i in range(n)]
for aa in itertools.permutations(a):
    cnt +=1
    idx = aa[0]
    xp,yp =  ls[idx]
    for idx in aa:
        x,y =  ls[idx]
        ans += ((x-xp)**2 + (y-yp)**2)**0.5
        xp ,yp = x,y
print(ans/cnt)

Solution (Python):
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

import numpy as np  






import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    X, Y = [0] * N, [0] * N
    for i in range(N):
        X[i], Y[i] = map(int, input().split())
    A=[i for i in range(N)]
    ans = 0
    cnt=0
    for k in permutations(A,N):
        for i in range(N-1):
            ans+=np.sqrt((X[k[i]]-X[k[i+1]])**2+(Y[k[i]]-Y[k[i+1]])**2)
        cnt+=1

    print(ans/cnt)

resolve()

Solution (Python):
import itertools
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

d = 0
c = 0
for x in itertools.permutations(xy):
  c += 1
  D = 0
  for i in range(N-1):
    D += ((x[i][0]-x[i+1][0]) ** 2 + (x[i][1]-x[i+1][1]) ** 2) ** 0.5
  d += D
ans = d / c
print(ans)

Solution (Python):
from math import sqrt

n = int(input())
total = 0
p = []
for _ in range(n):
    x, y = map(int, input().split())
    p.append([x, y])

for i in range(n - 1):
    for j in range(i, n):
        xi, yi = p[i]
        xj, yj = p[j]
        total += sqrt((xi -xj) ** 2 + (yi - yj) ** 2)

ans = total / n * 2
print(ans)

Solution (Python):
from itertools import permutations

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

dist = 0
cnt = 0
for pattern in permutations(xy):
    cnt += 1
    for i in range(n - 1):
        x1, y1 = pattern[i]
        x2, y2 = pattern[i + 1]
        dist += pow(pow(x1 - x2, 2) + pow(y1 - y2, 2), 1 / 2)
res = dist / cnt
print(res)

Solution (Python):
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

import math

dist_sum = 0
for i in range(N):
    xi, yi = xy[i]
    for j in range(N):
        xj, yj = xy[j]
        dist_sum += math.sqrt((xi - xj) ** 2 + (yi - yj) ** 2)

print(dist_sum / N)

Solution (Python):
N=int(input())
XY=[tuple(map(int, input().split())) for _ in range(N)]

from math import sqrt
def dist(a,b):
    return sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)
from itertools import permutations
a=b=0
for p in permutations(range(N)):
    b+=1
    for i in range(N-1):
        a+=dist(XY[p[i]], XY[p[i+1]])
print(a/b)

Solution (Python):
n = int(input())
X = []
Y = []

for i in range(n):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

import math
import itertools
ans = 0
for p in list(itertools.permutations(range(n))):
    for i in range(len(p)):
        if i == len(p)-1:
            continue
        ans += math.sqrt((X[p[i]]-X[p[i+1]])**2+(Y[p[i]]-Y[p[i+1]])**2)
ans /= math.factorial(n)
print(ans)

Solution (Python):
from itertools import permutations
from math import factorial
N = int(input())
X, Y = zip(*tuple(map(int, input().split()) for _ in range(N)))


def dist(x, xx, y, yy):
    return ((x - xx) ** 2 + (y - yy) ** 2) ** 0.5


d = 0
for p in permutations(range(N)):
    tmp = 0
    for s, t in zip(p, p[1:]):
        x = X[s]
        y = Y[s]
        xx = X[t]
        yy = Y[t]
        tmp += dist(x, xx, y, yy)
    d += tmp

print(d/factorial(N))

Solution (Python):
def main():
    N = int(input())
    XY = [[int(i) for i in input().split()] for j in range(N)]
    from itertools import permutations
    from math import hypot
    ans = 0
    for p in permutations(range(N)):
        cur = 0
        pre = p[0]
        for i in p[1:]:
            cur += hypot(XY[pre][0] - XY[i][0], XY[pre][1] - XY[i][1])
            pre = i
        ans += cur
    fa = 1
    for i in range(2, N+1):
        fa *= i
    print(ans/fa)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
xy=[list(map(int,input().split()))for _ in range(n)]
from itertools import permutations
ans=0
for i in permutations(range(n),n):
	for j in range(1,n):
		x,y=j-1,j
		ans+=((xy[i[x]][0]-xy[i[y]][0])**2+(xy[i[x]][1]-xy[i[y]][1])**2)**0.5
for i in range(n):ans/=i+1
print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n = INT()
xy = [LIST() for _ in range(n)]
c = list(permutations(xy, n))
ans = 0
for i in range(len(c)):
    for j in range(1, n):
        ans += sqrt((c[i][j][0] - c[i][j - 1][0]) ** 2 + (c[i][j][1] - c[i][j - 1][1]) ** 2)
ans /= len(c)
print(ans)

Solution (Python):
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]

import itertools
from math import hypot
z = a = 0
for ptn in itertools.permutations(XY):
    a += 1
    for (x1,y1),(x2,y2) in zip(ptn,ptn[1:]):
        z += hypot(x1-x2, y1-y2)
print(z/a)

Solution (Python):

N=int(input())
S = [list(map(int, input().split())) for i in range(N)]


from itertools import permutations
import math
from statistics import mean
junban =[ t for t in permutations(range(N)) ]

j_len =len(junban) 
x =[] 
x_sum =[]
def kyori(a,b): 
    return math.sqrt(pow( S[a][0]-S[b][0],2) + pow( S[a][1] - S[b][1],2) )


from itertools import combinations
kumiawase = [t for t in combinations(range(N), 2)]
kyori_all ={i:kyori(i[0],i[1]) for i in kumiawase}


for i in junban:
    for ji,jv in enumerate(i[:-1]):
        if i[ji]<i[ji+1]:
            x.append(kyori_all[ i[ji],i[ji+1] ] )
        if i[ji+1]<i[ji]:
            x.append(kyori_all[ i[ji+1],i[ji] ] )

    y =sum(x)    
    x_sum.append(y)
    x.clear()
kotae =mean(x_sum) 

print(kotae)

Solution (Python):
def main():
    from collections import namedtuple
    from itertools import combinations

    City = namedtuple('City', 'x y')

    def dist(a: City, b: City) -> float:
        dx = a.x - b.x
        dy = a.y - b.y
        return (dx * dx + dy * dy) ** 0.5

    N = int(input())

    cities = []
    for _ in range(N):
        x, y = map(int, input().split())
        c = City(x=x, y=y)
        cities.append(c)

    total = 0
    for comb in combinations(cities, r=2):
        total += dist(*comb)

    ans = total * 2 / N
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    from collections import namedtuple
    from itertools import permutations
    from math import factorial

    City = namedtuple('City', 'x y')

    def dist(a: City, b: City) -> float:
        dx = a.x - b.x
        dy = a.y - b.y
        return (dx * dx + dy * dy) ** 0.5

    N = int(input())

    cities = []
    for _ in range(N):
        x, y = map(int, input().split())
        c = City(x=x, y=y)
        cities.append(c)

    total = 0
    for perm in permutations(cities):
        it = iter(perm)
        p = next(it)

        for city in it:
            total += dist(p, city)
            p = city

    ans = total / factorial(N)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
xy=[]
for i in range(n):
    x,y=map(int,input().split())
    xy.append([x,y])
from itertools import permutations
ans=[]
for a in list(permutations(xy)):
    d=0.0
    for i in range(len(a)-1):
        d+=((a[i+1][0]-a[i][0])**2+(a[i+1][1]-a[i][1])**2)**0.5
    ans.append(d)
print(sum(ans)/len(ans))

Solution (Python):
n=int(input())
x=[]
y=[]
for i in range(n):
  a,b=map(int,input().split())
  x.append(a)
  y.append(b)

def fac(n):
  if n==0:
    return 1
  if n==1:
    return 1
  return n*fac(n-1)

ans=0
for i in range(n):
  for j in range(n):
    tmp=(((x[i]-x[j])**2+(y[i]-y[j])**2)**.5)
    ans+=tmp
   

print(ans/n)

Solution (Python):
n = int(input())
xy = []
for i in range(n):
  arrat = [int(i) for i in input().split()]
  xy.append(arrat)

ans = 0
for i in range(n):
  for j in range(i+1,n):
    ans += ((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5

ans /= n
print(ans*2)

Solution (Python):
def examA():
    def calc_L(x1,y1,x2,y2):
        return ((x2-x1)**2 + (y2-y1)**2)**0.5
    N = I()
    X = [LI()for _ in range(N)]
    ans = 0
    for x in itertools.permutations(X):
        cur = 0
        for i in range(1,N):
            cur += calc_L(x[i-1][0],x[i-1][1],x[i][0],x[i][1])
        
        ans += cur
    for i in range(1,N+1):
        ans /= i
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examA()

"""

"""

Solution (Python):
import math
n = int(input())
xy = [list(map(int,input().split()))for _ in range(n)]
perm=[0]*n
res = []
used = [0] *n
def dfs(depth):
    if depth == n:
        res.append([perm[i] for i in range(n)])
        return
    for i in range(n):
        if used[i]:continue
        used[i] = 1
        perm[depth] = i
        dfs(depth+1)
        used[i] = 0
dfs(0)
ans = 0
for p in res:
    for i in range(len(p)-1):
        x1,y1 = xy[p[i]][0],xy[p[i]][1]
        x2,y2 = xy[p[i+1]][0],xy[p[i+1]][1]
        dist = math.sqrt((x1-x2)**2+(y1-y2)**2)
        ans +=dist
P = [1]
for i in range(n):
    P.append(P[-1]*(i+1))
    
ans/=P[n]
print(ans)

Solution (Python):


from itertools import permutations
import math


N = int(input())
distance_list = []
for i in range(N):
    x, y = map(int, input().split())
    distance_list.append([x, y])


distance = 0
pattern_num = 0
pattern_moto = [i for i in range(1, N+1)]
for p in permutations(pattern_moto):
    pattern_num += 1
    tmp_distance = 0
    for d in range(len(p)-1):
        d_1 = distance_list[p[d]-1]
        d_2 = distance_list[p[d+1]-1]
        tmp = math.sqrt((d_1[0]-d_2[0])**2 + (d_1[1]-d_2[1])**2)
        tmp_distance += tmp
    distance += tmp_distance


distance = distance / pattern_num
print(distance)

Solution (Python):
from itertools import permutations
from math import sqrt

N = int(input())
xy = []
for _ in range(N):
    x, y = map(int, input().split())
    xy.append((x, y))


_sum = 0
for p in permutations(range(N)):
    s = p[0]
    x, y = xy[s]
    for i, pi in enumerate(p):
        if i == 0:
            continue
        nx, ny = xy[pi]
        d = (nx-x)**2 + (ny-y)**2
        _sum += sqrt(d)

a = 1
for i in range(1, N+1):
    a *= i
print(_sum/a)