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):
import sys,math
import itertools

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	pos = LLI(N)
	dist = [[0 for _ in range(N)] for _ in range(N)]
	total = 0
	for i in range(N):
		for j in range(i+1,N):
			dist[i][j] = math.sqrt((pos[i][0]-pos[j][0])**2 + (pos[i][1]-pos[j][1])**2)
			dist[j][i] = dist[i][j]
		total += sum(dist[i])
	print(total/N)

main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

city = [LIST() for _ in range(N)]

per = [i for i in range(N)]

a = list(permutations(per))

sums = 0
for i in a:
	path = 0
	for j in range(N - 1):
		path += sqrt((city[i[j]][0] - city[i[j+1]][0])**2 + (city[i[j]][1] - city[i[j+1]][1])**2 )
	sums += path

print(sums/len(list(a)))

Solution (Python):
n=int(input())
distance=[list(map(int,input().split())) for i in range(n)]

import itertools
import math
temp=[i for i in range(n)]
perm=list(itertools.permutations(temp))

sm=0
count=0
for route in perm:
    count+=1
    temp_dis=0
    route_list=list(route)
    for i in range(1,n):
        j=route_list[i]
        k=route_list[i-1]
        temp_dis+=math.sqrt((distance[j][0]-distance[k][0])**2+(distance[j][1]-distance[k][1])**2)
    sm+=temp_dis
ans=sm/count
print('{:.9f}'.format(ans))

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

import itertools,math

ptr = list(itertools.permutations(range(N),N))

def dist(p1,p2):
  return math.sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)

total = 0

for pt in ptr:
  for i in range(len(p)-1):
    total += dist(p[pt[i]] ,p[pt[i+1]])  
print(total/len(ptr))

Solution (Python):
import itertools
N = int(input())
root = []
for i in range(N):
    num= [int(i) for i in input().split()]
    root.append(num)


n_list = list(itertools.permutations(root))
dist1 = []
for i in n_list:
    dist = 0
    for j in range(1,N):
        dist = dist + ((i[j][0]-i[j-1][0])**2+(i[j][1]-i[j-1][1])**2)**(1/2)
    dist1.append(dist)
print(sum(dist1)/len(dist1))

Solution (Python):
import math
N=int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
cnt = 0
for i in range(N-1):
    for j in range(i+1,N,1):
        cnt +=math.sqrt((A[i]-A[j])**2+(B[i]-B[j])**2)
print(cnt*2/N)

Solution (Python):
import math
from itertools import permutations


class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def distance_to(self, p):
        dx = p.x - self.x
        dy = p.y - self.y
        return math.sqrt(dx * dx + dy * dy)


def route_distance(ps):
    if len(ps) < 2:
        return 0
    else:
        return ps[0].distance_to(ps[1]) + route_distance(ps[1:])


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

    sum_routes = sum(route_distance(ps) for ps in permutations(ps, N))
    print(sum_routes / math.factorial(N))


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
xy = []
for _ in range(n):
	xy.append([int(x) for x in input().split()])
dis = 0
for x1, y1 in xy:
	for x2, y2 in xy:
		
		dis += ((x1 - x2)**2 + (y1 - y2)**2)**0.5
print(dis/n)

Solution (Python):
import itertools
n = int(input())
point = []
for i in range(n):
  a,b = map(float,input().split())
  point.append((a,b))
ans = 0.0
div = 0
for pm in itertools.permutations(point):
  div += 1
  for j in range(n-1):
    ans += ((pm[j][0]-pm[j+1][0])**2 + (pm[j][1]-pm[j+1][1])**2) ** 0.5
print(ans / div)

Solution (Python):
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
XY = np.array(read().split(), np.int64)

X = XY[::2]
Y = XY[1::2]

dx = X[None, :] - X[:, None]
dy = Y[None, :] - Y[:, None]

dist_mat = (dx * dx + dy * dy) ** .5
ans = dist_mat.sum() / N

print(ans)

Solution (Python):
import sys
import math
sys.setrecursionlimit(10 ** 7)

N = int(input())
CITY = [[int(x) for x in input().split()] for _ in range(N)]

l = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        ci = CITY[i]
        cj = CITY[j]
        d = math.sqrt((ci[0] - cj[0]) ** 2 + (ci[1] - cj[1]) ** 2)
        l += math.factorial(N - 1) * d

print(l / math.factorial(N))

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

N = int(input())
l = [tuple(map(int, input().split())) for _ in range(N)]
ans = 0
n = 0

for i in permutations(l):
    for j in range(N-1):
        x1, y1 = i[j]
        x2, y2 = i[j+1]
        ans += sqrt((x1-x2)**2+(y1-y2)**2)
    n += 1

print(ans/n)

Solution (Python):
import numpy as np

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

res = 0
for i in range(len(m)):
    for j in range(i+1, len(m)):
        res += np.sqrt((m[i][0] - m[j][0]) ** 2 + (m[i][1] - m[j][1]) ** 2)
        
print(res * 2 / N)

Solution (Python):
import math
import itertools

n = int(input())
xy = [ list(map(int, input().split())) for _ in range(n) ]
p = itertools.permutations(xy, n)
c = 0
for i in p:
  for j in range(n-1):
    c += ( (i[j][0]-i[j+1][0])**2 + (i[j][1]-i[j+1][1])**2 )**0.5
    
l = math.factorial(n)
print(c/l)

Solution (Python):
n = int(input())
list = []
for i in range(n):
  a = [int(j) for j in input().split()]
  list.append(a)
  
root = []
for i in range(n):
  for j in range(i+1, n, 1):
    a = list[i]
    b = list[j]
    r =  ((a[0]-b[0])**2 + (a[1]-b[1])**2)**(1/2)
    root.append(r)
    
print((sum(root)*(n-1))/((n*(n-1))/2))

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

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

w = 0
for X in permutations(range(n)):
    x0, y0 = poses[X[0]]
    z = 0
    for i in X[1:]:
        x, y = poses[i]
        z += sqrt((x0-x)**2 + (y0-y)**2)
        x0, y0 = x, y
    w += z
print(w / factorial(n))

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

dis = 0

for x1, y1 in xy:
    for x2, y2 in xy:
        dis += ((x1 - x2)**2 + (y1 - y2)**2)**0.5

print(dis/n)

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

import math

dist = 0
for i in range(N-1):
  for j in range(i+1, N):
    dist = dist + math.sqrt((x[i][0]-x[j][0])**2 + (x[i][1]-x[j][1])**2)

ans = dist * 2 / N
print(ans)

Solution (Python):
N = int(input())
chart = [[int(x) for x in input().split()] for _ in range(N)]
LL = []
for i in range(N):
    for j in range(i,N):
        LL.append(((chart[i][0]-chart[j][0])**2 + (chart[i][1]-chart[j][1])**2)**0.5)

def kaijo(N):
    ans = 1
    for i in range(1,N+1):
        ans = ans*i
    return ans

print(sum(LL)*2*kaijo(N-1)/kaijo(N))

Solution (Python):
import math
n = int(input())

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


for i in range(n-1):
    for j in range(i+1, n):
        distance = math.sqrt((coord_list[i][0] - coord_list[j][0]) ** 2 + (coord_list[i][1] - coord_list[j][1]) ** 2)      
        all_distances += distance
        

print(all_distances * 2 / n)

Solution (Python):
import math
import itertools
n = int(input())
a = []
for i in range(n):
	x,y = map(int, input().split())
	a.append([x,y])
x = 0
y = 0
s = 0
b = []
c = 0
for i in itertools.permutations(a):
	x = i[0][0]
	y = i[0][1]
	s = 0
	c += 1
	for xx,yy in i[1:]:
		s += math.sqrt((x-xx)**2 + (y-yy)**2)
		x = xx
		y = yy
	b.append(s)
print (sum(b)/c)

Solution (Python):
N = int(input())
town = [None]*N

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

avr_temp = 0
for i in range(N):
    for j in range(i+1, N):
        
        avr_temp += ((town[i][0]-town[j][0])**2+(town[i][1]-town[j][1])**2)**0.5
avr = avr_temp * 2 / N
print(avr)

Solution (Python):
n = int(input())
X, Y = [0]*n, [0]*n
for i in range(n):
    X[i], Y[i] = map(int, input().split())

r = 0
for i in range(n-1):
    for j in range(i+1, n):
        r += ((X[i]-X[j])**2+(Y[i]-Y[j])**2)**0.5
print((n-1)*r/(n*(n-1)//2))

Solution (Python):
import math
def dist(A,B):
    a,b = A
    c,d = B
    return math.sqrt((a-c)**2 + (b-d) **2)
import itertools
N = int(input())
L = list(itertools.permutations([_ for _ in range(1,N+1)]))
res = 0
City = []
for _ in range(N):
    x,y = map(int,input().split())
    City.append((x,y))
for s in L:
    for i in range(0,len(s)-1):
        res += dist(City[s[i]-1],City[s[i+1]-1])
print(res/math.factorial(N))

Solution (Python):
import itertools, math

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

ans = 0
pat = list(itertools.permutations(city))
for c in pat:
  l = 0
  for j in range(N-1):
    l += math.sqrt(pow(c[j][1][0] - c[j+1][1][0], 2) + pow(c[j][1][1] - c[j+1][1][1], 2))
  ans += l
print(ans/len(pat))

Solution (Python):
N=int(input())
X=[]
for i in range(N):
    X.append(list(map(int,input().split())))

total_d=0
for i in range(N):
    for j in range(i):
        total_d+=((X[i][0]-X[j][0])**2+(X[i][1]-X[j][1])**2)**0.5
ans=total_d*2/N
print(ans)

Solution (Python):
import itertools
import math

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

p = itertools.permutations(p, n)

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

print(sum(l) / len(l))

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

for i in range(N-1):
  for j in range(i+1, N):
    dist += math.sqrt((towns[j][0] - towns[i][0])**2 + (towns[j][1] - towns[i][1])**2)

print(dist * 2 / N)

Solution (Python):
N = int(input())
X_Y = [list(map(int, input().split())) for _ in range(N)]
root_Num = 0
total_root_Num = 1
for i in range(1,N):
    root_Num += i
for i in range(1,N+1):
    total_root_Num *= i
total_root_Num *= N-1
No = total_root_Num // root_Num 
dis = [0] * root_Num
total_dis = 0
for i in range(N):
    for j in range(i+1,N):
        total_dis += ((X_Y[i][0]-X_Y[j][0])**2 + (X_Y[i][1]-X_Y[j][1])**2)**(0.5)       
total_dis *= No
ans = total_dis/(total_root_Num /( N-1))
print(ans)

Solution (Python):
import math

def dis(x1, y1, x2, y2):
    return ((x1 - x2)**2 + (y1 - y2)**2) ** (1/2)

def kaijo(n):
    return math.factorial(n)

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

sum = 0

for j in range(n):
    for i in range(n):
        if i != j:
            sum = sum + (dis(x[i], y[i], x[j], y[j])) * kaijo(n-1)

print(sum/kaijo(n))

Solution (Python):
import math
n = int(input())
loc = list()

def getDist(x,y):
    return math.sqrt((x[0] - y[0])**2 + (x[1]-y[1])**2)

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

for i in range(n):
    x,y = list(map(int,input().split(" ")))
    loc.append((x,y))

total = 0
for i in range(n):
    for j in range(i):
        total += getDist(loc[i],loc[j]) * 2 * (n-1) * fac(n-2)

avg = total / fac(n)
print(avg)

Solution (Python):

import itertools

n = int(input())
x = ["" for _ in range(n)]
y = ["" for _ in range(n)]

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

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

seq = list(range(n))
lis = list(itertools.permutations(seq))


means = []
for s in lis:
    total_dist = []
    for i in range(len(s)-1):
        x1 = x[s[i]]
        x2 = x[s[i+1]]
        y1 = y[s[i]]
        y2 = y[s[i+1]]
        total_dist.append(dist(x1, x2, y1, y2))
    means.append(sum(total_dist))

print(sum(means)/len(means))

Solution (Python):
import numpy as np
import math
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

def dist(i,j):
  return np.sqrt((e[i][0]-e[j][0]) ** 2 + (e[i][1]-e[j][1]) ** 2)

if n == 2:
  print(dist(0,1))
else:
  a = math.factorial(n-1)
  ans=0
  for i in range(n):
    for j in range(n):
      ans += dist(i,j) * a
  ans = ans / math.factorial(n)
  print(ans)

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

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

def dist(xy1, xy2):
  x1, y1 = xy1
  x2, y2 = xy2
  return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

answer = 0
for i in range(N):
  for j in range(i + 1, N):
    answer += dist(XY[i], XY[j]) / (N / 2)

print(answer)

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

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

def dist(xy1, xy2):
  x1, y1 = xy1
  x2, y2 = xy2
  return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

answer = 0
for i in range(N):
  for j in range(i + 1, N):
    answer += dist(XY[i], XY[j]) / (N / 2)

print(answer)

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

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

def dist(xy1, xy2):
  x1, y1 = xy1
  x2, y2 = xy2
  return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

tmp = 0
for i in range(N):
  for j in range(i + 1, N):
    tmp += dist(XY[i], XY[j]) / (N / 2)

print(tmp)

Solution (Python):
import itertools
import math

N = int(input())

array = list(range(N))
ckyori_list = list(itertools.combinations(array, 2))
path_list = list(itertools.permutations(array))
kyori_list = [[ 0 for i in range(N)] for j in range(N)]

cmap = []
for i in range(N):
    temp = list(map(int, input().split(" ")))
    cmap.append(temp)
    
for i,j in ckyori_list:
    kyori_list[i][j] = math.sqrt((cmap[i][0]-cmap[j][0])**2 + (cmap[i][1]-cmap[j][1])**2)
    kyori_list[j][i] = kyori_list[i][j]

sum = 0
for i in path_list:
    for j in range(len(i)-1):
        sum += kyori_list[i[j]][i[j+1]]
        
print(sum/len(path_list))

Solution (Python):
import itertools
import math

N = int(input())
crd_list = []
for _ in range(N):
    crd_list.append([int(xy) for xy in input().split()])

cost_list = []
for way in itertools.permutations([n for n in range(N)]):
    cost = 0
    for index in range(1, N):
        cost += ((crd_list[way[index]][0]-crd_list[way[index-1]][0])**2 + (crd_list[way[index]][1]-crd_list[way[index-1]][1])**2)**0.5
    cost_list.append(cost)

print(sum(cost_list)/math.factorial(N))

Solution (Python):


MOD = 10 ** 9 + 7
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
s = sum([math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2) for i in range(n) for j in range(n)])

ans = s / n

print(ans)

Solution (Python):
import sys
import itertools
import math

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    
    tokens = iterate_tokens()
    N = int(next(tokens))
    x_list = []
    y_list = []
    for i in range(N):
        x_list.append(int(next(tokens)))
        y_list.append(int(next(tokens)))

    solve(N, x_list, y_list)

def solve(N: int, x_list: list, y_list: list):
    total_dist = 0
    for n_iter in itertools.permutations(range(N)):
        total_dist += measure_distance(n_iter, x_list, y_list)
    print(total_dist/math.factorial(N))
    return

def measure_distance(n_iter: tuple, x_list: list, y_list: list):
    dist = 0
    for i in range(len(n_iter)-1):
        tmp_dist_x = x_list[n_iter[i]] - x_list[n_iter[i+1]]
        tmp_dist_y = y_list[n_iter[i]] - y_list[n_iter[i+1]]
        dist += math.sqrt(tmp_dist_x**2 + tmp_dist_y**2)
    return dist

if __name__ == "__main__":
    propare()

Solution (Python):
import itertools
import math

N = int(input())
li = [list(map(int, input().split())) for k in range(N)]
r = []

total = []

for i in itertools.permutations(range(N)):
  r.append(i)


for i in r:
  count = 0
  for s in range(len(i)):
    if s + 1 > len(li) - 1:
      break

    town = i[s]
    nextTown = i[s+1]

    count += math.sqrt(((li[nextTown][0] - li[town][0]) ** 2) + ((li[nextTown][1] - li[town][1]) ** 2))

  total.append(count)

print(sum(total) / len(total))

Solution (Python):

import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache
import heapq

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    X = cin.intListList(N)
    R = list(itertools.permutations(range(N)))
    ans = 0
    for p in R:
        l = 0.0
        for i in range(N - 1):
            x = X[p[i + 1]][0] - X[p[i]][0]
            y = X[p[i + 1]][1] - X[p[i]][1]
            l += (x ** 2 + y ** 2) ** 0.5
        ans += l
    ans /= len(R)
    print(ans)
    return

if __name__ == "__main__":
    main()

Solution (Python):
def permutation(lst):
    if len(lst) == 0:
        return []
    if len(lst) == 1:
        return [lst]
    res = []
    for i in range(len(lst)):
       m = lst[i]
       remLst = lst[:i] + lst[i+1:]
       for p in permutation(remLst):
           res.append([m] + p)
    return res

dist = lambda x1, y1, x2, y2 : ((x1-x2)**2 + (y1-y2)**2)**.5
n = int(input())
d = [[0] * n for _ in range(n)]
pnts = []
for _ in range(n):
	x, y = map(int, input().split())
	pnts.append((x, y))
for i in range(n):
	for j in range(n):
		d[i][j] = d[j][i] = dist(pnts[i][0], pnts[i][1], pnts[j][0], pnts[j][1])
paths = permutation(list(range(n)))
res = 0
for path in paths:
    for j in range(n-1):
        res += d[path[j]][path[j+1]]
print(round(res/len(paths), 6))

Solution (Python):

"""
Created on Fri Jan 24 18:25:41 2020
abc145c
@author: manakamura
"""

n = int(input())

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


dis=[]

sum=0
for i in range(0,n):
    tmp=[]
    for j in range(0,i):
        tmp.append(dis[j][i])
    tmp.append(1)
    for j in range(i+1,n):
        l=0
        l+=(x[j]-x[i])**2
        l+=(y[j]-y[i])**2
        l=l**0.5
        sum+=l
        tmp.append(l)

    dis.append(tmp)



print(sum*2/n)

Solution (Python):
import math
import itertools

n = int(input())
List = [list(map(int, input().split())) for i in range(n)]
dis_sum, count = 0, 0
for v in itertools.permutations(List):
    for i in range(len(v)-1):
        z = (v[i][0]-v[i+1][0])**2 + (v[i][1]-v[i+1][1])**2
        dis = math.sqrt(z)
        dis_sum += dis
    count += 1
print(dis_sum/count)

Solution (Python):
import itertools
from itertools import permutations
from math import factorial, hypot

n = int(input())
x, y = [], []

for i in range(n):
    x1, y1 = [int(j) for j in input().split()]
    x.append(x1)
    y.append(y1)

ans = 0

order = [i for i in range(n)]

for status in itertools.permutations(order, n):
    tmp = 0
    for i in range(n - 1):
        tmp += hypot(x[status[i]] - x[status[i + 1]], y[status[i]] - y[status[i + 1]])
    ans += tmp

print(ans / factorial(n))

Solution (Python):
import itertools
import math
N = int(input())
A = []
ans = 0
t = 0
for _ in range(N):
  a = list(map(int,input().split()))
  A.append(a)
def D(x0,y0,x1,y1):
  d = math.sqrt((x1-x0)**2+(y1-y0)**2)
  return d

r = []
for i in range(N):
  r.append(i)

for row in itertools.permutations(r,N):
  t += 1
  for i in range(N-1):
    p = row[i]
    q = row[i+1]
    x0,y0 = A[p]
    x1,y1 = A[q]
    ans += D(x0,y0,x1,y1)

print(ans/t)

Solution (Python):
from math import factorial

N = int(input())
li = [[int(zz) for zz in input().split()] for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += ((li[i][0]-li[j][0])**2+(li[i][1]-li[j][1])**2)**(1/2)

print(ans*2/N)

Solution (Python):
n = int(input())

cordinates = [[0] * 2 for i in range(n)]
for i in range(n):
  cordinates[i][0], cordinates[i][1] = map(int, input().split())

sum = 0
for i in range(n):
  for j in range(n):
    
    sum += (n-1)*(((cordinates[i][0] - cordinates[j][0])**2 + (cordinates[i][1] - cordinates[j][1])**2)**0.5)

print(sum / (n*(n-1)))

Solution (Python):
import math
n = int(input())
p = {}
for i in range(n):
    x,y = map(int, input().split())
    p[i] = (x, y)
ave = 0
for i in range(n):
    for j in range(i+1,n):
        ave += math.sqrt(abs(p[i][0] - p[j][0])**2 + abs(p[i][1] - p[j][1])**2)
ave /= ((n*(n-1))/2)
total = ave*(n-1)
print(total)

Solution (Python):
from itertools import permutations
from math import factorial
N=int(input())
D=[tuple(map(int,input().split())) for _ in range(N)]
ans=0
for d in permutations(D):
    for i in range(N-1):
        ans+=((d[i][0]-d[i+1][0])**2+(d[i][1]-d[i+1][1])**2)**0.5
print(ans/factorial(N))

Solution (Python):
n = int(input())
ll = [list(map(int,input().split())) for _ in range(n)]
d = 0
for x1,y1 in ll:
  for x2,y2 in ll:
    d += ((x1-x2)**2+(y1-y2)**2)**0.5
print(d/n)

Solution (Python):
n = int(input())
ll = []
for i in range(n):
  ll.append(list(map(int, input().split())))

import itertools as it
lt = list(it.permutations(range(0, n)))

def dist(i, j):
  return ((ll[i][0]-ll[j][0])**2 + (ll[i][1]-ll[j][1])**2)**0.5

d = 0

for t in lt:
  for i in range(n-1):
    d += dist(t[i], t[i+1])

print(d/len(lt))

Solution (Python):
import math

n = int(input())
List = [list(map(int, input().split())) for i in range(n)]
dis_list = []
for i in range(n):
    for j in range(n):
        if i != j:
            z = (List[i][0]-List[j][0])**2 + (List[i][1]-List[j][1])**2
            dis = math.sqrt(z)
            dis_list.append(dis)
print(sum(dis_list)/n)

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

total_length = 0
for i in range(n):
    position = list(map(int, input().split()))
    town_map.append(position)
    for j in range(i):
        total_length += ((position[0] - town_map[j][0]) ** 2 + (position[1] - town_map[j][1]) ** 2) ** (1/2)

print(total_length * 2 / n)

Solution (Python):
import itertools
import math

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

def dist_p(p1, p2):
    return dist(p1[0], p2[0], p1[1], p2[1])

n = int(input())
c = []

for i in range(n):
    xi,yi = map(int, input().split())
    c.append((xi, yi))

l = list(itertools.permutations(c))

sum = 0
for e in l:
    for i in range( len(e)-1 ):
        sum += dist_p(e[i], e[i+1])

print(sum/len(l))

Solution (Python):
import itertools,math
N=int(input())
T=[list(map(int,input().split())) for i in range(N)]
D=0
U=[]
def f(U):
  d=((U[0][0]-U[1][0])**2+(U[0][1]-U[1][1])**2)**0.5
  return d


for i in list(itertools.permutations(range(1,N+1))):
  for j in range(1,N):
    U+=[T[i[j-1]-1],T[i[j]-1]]

    D+=f(U)

    U=[]
print(D/math.factorial(N))

Solution (Python):
import math

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

s = 0.0
for i in range(n-1):
    for j in range(i+1, n):
        s += math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
        

print(2*s/n)

Solution (Python):
import math

N = int(input())
xy = []
N_root = math.factorial(N)
distance = 0

for i in range(N):
    xy.append( list(map(int, input().split())) )

for i in range(N):
    
    for j in range(i+1, N):
        
        tmp = (xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2
        distance += math.sqrt(tmp)

distance *= 2 * math.factorial(N-1)

print(distance/N_root)

Solution (Python):
import itertools
import math

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

s = 0
for _p in itertools.permutations(xy, n):
    for i in range(0, n-1):
        s += math.sqrt((_p[i][0]-_p[i+1][0])**2 + (_p[i][1]-_p[i+1][1])**2)

print(s/math.factorial(n))

Solution (Python):
n = int(input())
a=[]
for _ in range(n):
  a.append(list(map(int, input().split())))

ans = 0.0
for i in range(n):
  for j in range(n):
    if i == j: continue
    ans += ((a[i][0]-a[j][0]) ** 2 + (a[i][1]-a[j][1]) ** 2) ** 0.5
ans = ans / 2

ans = 2/n *ans
print(ans)

Solution (Python):
import itertools

def powpow(xl,yl):
    tmp = pow(xl[0]-yl[0], 2) + pow(xl[1]-yl[1], 2)
    dist = pow(tmp, 0.5)
    return dist


def main():
    n = int(input())
    num_list = [list(map(int, input().split())) for _ in range(n)]

    sum = 0

    ls = []
    for i in range(n):
        ls.append(i+1)

    p_list = list(itertools.permutations(ls, n))

    for i in range(len(p_list)):
        for j in range(n-1):
            xl = num_list[p_list[i][j] - 1]
            yl = num_list[p_list[i][j+1] - 1]
            sum += powpow(xl,yl)

    print(sum/len(p_list))

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
import itertools
import math
town = []
gokei = 0
for _ in range(N):
    town.append(list(map(int, input().split())))
for i in itertools.permutations(town):
    for k in range(N-1):
        gokei += math.sqrt((i[k][0]-i[k+1][0])**2+(i[k][1]-i[k+1][1])**2)
print(gokei/math.factorial(N))

Solution (Python):
import itertools
N = int(input())
XY = tuple(tuple(map(int, input().split())) for _ in range(N))
kumi = tuple(itertools.permutations(XY, N))
ans = 0
def f(xi, yi, xj, yj):
    return ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5

for i in kumi:
    for j in range(N-1):
        xi, yi = i[j]
        xj, yj = i[j+1]
        ans += f(xi, yi, xj, yj)
print(ans/len(kumi))

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

def length(a, b):
  return ((X[a]-X[b])**2 + (Y[a]-Y[b])**2)**0.5
def total_len(L):
  n = len(L)
  total = 0
  for i in range(n-1):
    total += length(L[i], L[i+1])
  return total

from itertools import permutations as prm
import math
s = 0
for i in prm(list(range(0, n)), n):
  s += total_len(i)
print(s / math.factorial(n))

Solution (Python):
n=int(input())
a=[]
b=[]
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    for j in range(n):
        b.append(((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5)
print((sum(b)/(len(b)-n))*(n-1))

Solution (Python):
import math

n = int(input())
D = list()
for _ in range(n):
    D.append(list(map(int,input().split())))

sum_d = 0
cnt = 0
for i in range(n):
    for j in range(n):
        xx = math.sqrt((D[i][0]-D[j][0])**2+(D[i][1]-D[j][1])**2)
        sum_d += xx
        cnt += 1
print(sum_d/n)

Solution (Python):
import math

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

total_distance = 0
count = 0

for i in range(n):
    for j in range(n):
        if i != j:
            total_distance += math.sqrt( (xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2 )
            count += 1

print(total_distance / n)

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

import itertools
ans = 0
def kaijou(n):
    if n==1:
        return 1
    else:
        return n*kaijou(n-1)


for v in itertools.permutations(L, N):
    for i in range(N-1):
        ans += ((XY[v[i]][0]-XY[v[i+1]][0])**2 + (XY[v[i]][1]-XY[v[i+1]][1])**2)**0.5
ans /= 1.0*kaijou(N)
print(ans)

Solution (Python):
xx=[]
yy=[]
n=int(input())
for ii in range(n):
    x,y=map(int,input().split())
    xx.append(x)
    yy.append(y)

dd=0.
for i1 in range(n):
    for i2 in range(n):
        dd=dd+((xx[i1]-xx[i2])**2+(yy[i1]-yy[i2])**2)**(0.5)
avedd=dd/n/(n-1)

dd2=avedd*(n-1)
print(dd2)

Solution (Python):





from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit







from math import factorial,hypot


setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
l=permutations(range(n),n)
dis=[]
d=[list(map(int,input().split())) for _ in range(n)]
now=0
for i in l:
    
    for j in range(n-1):
        now+=hypot((d[i[j]][0]-d[i[j+1]][0]),(d[i[j]][1]-d[i[j+1]][1]))
        
print(now/factorial(n))