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



Sample input:
3
0 0
1 0
0 1


Sample output:
2.2761423749

Submission status: Wrong Answer

Solution code:
from itertools import combinations
n = int(input())
a = list(list(map(int, input().split()))for _ in range(n))
sum = 0
for i in list(combinations(a, 2)):
    sum += ((i[0][0] - i[1][0])**2 + (i[0][1] - i[1][1])**2)**0.5
t = 1
for k in range(1, n):
    t *= k
print(sum*(n-1)/n)

Submission status: Wrong Answer

Solution code:
import itertools
 
N = int(input())
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
Ave = dis / N
print(Ave)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
total=0
route=list(itertools.combinations(X,2))
print(route)
for i in route:
    total+=((i[0][0]-i[1][0])**2+(i[0][1]-i[1][1])**2)**(1/2)
print(total*2/N)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x,y=[0]*N,[0]*N
ans=0
for i in range(N):
    x[i],y[i]=map(int,input().split())
    if i==0:
        pass
    else:
        ans+=math.sqrt(pow(x[i-1]-x[i],2)+pow(y[i-1]-y[i],2))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=[]
for _ in range(n):
    a.append(list(map(int,input().split())))
s=0
for i in range(n):
    for j in range(n):
        if j!=i:
            s+=((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5
print((n-1)*s/math.factorial(n))

Submission status: Wrong Answer

Solution code:
# 12:03
import itertools
import math
n = int(input())

cities = [list(map(int, input().split())) for _ in range(n)]
print(cities)
a = []
for i in range(n):
    a.append(i)
a = list(itertools.permutations(a))
sum = 0
for city in a:
    for i in range(n-1):
        sum += ((cities[city[i+1]][0]-cities[city[i]][0])**2 +
                (cities[city[i+1]][1]-cities[city[i]][1])**2)**0.5
print(sum/math.factorial(n))

Submission status: Wrong Answer

Solution code:
import itertools
import math
N = int(input())
ll = list()
for n in range(N):
    l = list(map(int, input().split()))
    ll.append(l)
p = list()
for i in range(N):
    p.append(i)
p = itertools.permutations(p)
total = 0
for i in p:
    for s in range(len(i) - 1):
        total += math.sqrt((ll[s][0]-ll[s + 1][0])**2 + (ll[s][1]-ll[s + 1][1])**2)
print(total/float(math.factorial(N)))

Submission status: Wrong Answer

Solution code:
import itertools
import math
N = int(input())
ll = list()
for n in range(N):
    l = list(map(int, input().split()))
    ll.append(l)
p = list()
for i in range(N):
    p.append(i)

p = itertools.permutations(p)
total = 0
for i in p:
    for s in i:
        if s == len(i) - 2:
            total += math.sqrt((ll[s + 1][0]-ll[s][0])**2 + (ll[s + 1][1]-ll[s][1])**2)

total = total / len(i)
print(total)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
m = [list(map(int, input().split())) for _ in range(n)]
ans=0

for i in range(n):
    for j in range(i+1,n):
        ans+=math.sqrt((m[i][0]-m[j][0])**2 + (m[i][1]-m[j][1])**2)
        print(ans)
print(ans*2/n)

Submission status: Wrong Answer

Solution code:
#15
import math
n=int(input())
m = [list(map(int, input().split())) for _ in range(n)]
ans=0
d=math.factorial(n)
s=(n-1)*2
for i in range(n):
    for j in range(i+1,n):
        ans+=math.sqrt((m[i][0]-m[j][0])**2 + (m[i][1]-m[j][1])**2)
ans=ans/d
print(ans*s)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
m = [list(map(int, input().split())) for _ in range(n)]
ans=0
d=math.factorial(n)/((n-1)*2)
for i in range(n):
    for j in range(i+1,n):
        ans+=math.sqrt((m[i][0]-m[j][0])**2 + (m[i][1]-m[j][1])**2)
print(ans/d)

Submission status: Wrong Answer

Solution code:
import math
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    POS = [list(map(int, input().split())) for i in range(N)]
    DIS = [[0]*(N) for _ in range(N)]
    M = 1
    for i in range(1,N+1):
        M *= i
    for i in range(N):
        for j in range(N):
            DIS[i][j] = math.sqrt((POS[i][0] - POS[j][0])**2 +(POS[i][1] - POS[j][1])**2)
    print(sum(map(sum, DIS))*(N-1)/M)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    POS = [list(map(int, input().split())) for i in range(N)]
    DIS = [[0]*(N) for _ in range(N)]
    M = 1
    for i in range(1,N+1):
        M *= i
    print(M)
    for i in range(N):
        for j in range(N):
            DIS[i][j] = math.sqrt((POS[i][0] - POS[j][0])**2 +(POS[i][1] - POS[j][1])**2)
    print(sum(map(sum, DIS))*(N-1)/M)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools
import math

n = int(input())
towns_li = []
for _ in range(n):
    co = list(map(int, input().split()))
    towns_li.append(co)
di = 0
for i in itertools.permutations(range(n)):
    for j in range(n - 1):
        di += math.sqrt(((towns_li[j][0] - towns_li[j+1][0]) ** 2 + (towns_li[j][1] - towns_li[j+1][1]) ** 2))
print(di / math.factorial(n))

Submission status: Wrong Answer

Solution code:
from itertools import permutations as prm
import math
n = int(input())
X = [0] * n
Y = [0] * n
for i in range(n):
  X[i], Y[i] = map(int, input().split())

total_len = 0
for pattern in prm(range(n)):
  for i in range(n-1):
    total_len += ((X[i] - X[i+1])**2 + (Y[i] - Y[i+1])**2)**0.5
print(total_len / math.factorial(n))

Submission status: Wrong Answer

Solution code:
from math import sqrt,factorial
n = int(input())
l = []
for i in range(n):
  d = list(map(int,input().split()))
  l.append(d)
x = 2//n
ans = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans += x*sqrt(((l[i][0]-l[j][0])**2 + (l[i][1]-l[j][1])**2))
print(ans)

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))
print('bust' if sum(A) >=22 else 'win')

Submission status: Wrong Answer

Solution code:
n=int(input())
town=[]
for i in range(n):
  xy=list(map(int,input().split()))
  town.append(xy)
way=0
import math
for i in range(n-1):
  for j in range(i,n):
    ij=math.sqrt((town[i][0]-town[j][0])**2+(town[i][1]-town[j][1])**2)
    way=way+ij
print(way*2*(n-1)/n)

Submission status: Wrong Answer

Solution code:
n = int(input())
l, l1, l2 = list(""), list(""), list("")
for i in range(n):
    x, y = map(int, input().split())
    l1.append(x)
    l2.append(y)
for i in range(n - 1):
    for j in range(i + 1, n):
        l.append(((l1[i] -l1[j]) ** 2 + (l2[i] - l2[j]) ** 2) ** 0.5)
print('{:.10f}'.format(2 * sum(l) / len(l)))

Submission status: Wrong Answer

Solution code:
n = int(input())
l, l1, l2 = list(""), list(""), list("")
for i in range(n):
    x, y = map(int, input().split())
    l1.append(x)
    l2.append(y)
for i in range(n - 1):
    for j in range(i + 1, n):
        l.append(((l1[i] -l1[j]) ** 2 + (l2[i] - l2[j]) ** 2) ** 0.5)
print(l)
print('{:.10f}'.format(2 * sum(l) / len(l)))

Submission status: Wrong Answer

Solution code:
from itertools import permutations
import math

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

length = 0
for case in permutations(range(n)):
    cnt = 0
    for j in case:
        if cnt == 0:
            cnt += 1
            continue
        else:
            cnt += 1
            length += math.sqrt((pos[j-1][0] - pos[j][0])*(pos[j-1][0] - pos[j][0]) + (pos[j-1][1] - pos[j][1])*(pos[j-1][1] - pos[j][1]))
print(length/len(list(permutations(range(n)))))

Submission status: Wrong Answer

Solution code:
from math import sqrt, factorial
from itertools import permutations

def main():
    n = int(input())
    pos = []

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

    sum = 0
    for i in permutations(pos, 2):
        # 例:i=([x0,y0],[x1,y1])
        """
        1箇所線分を固定した場合のパス(経路)は(n-1)!通り
        例えば、全パスn!通りのうち、1→2の線分が出てくるパスは(n-1)!通り
        各線分の距離*(n-1)!を全線分加算すると全パスの合計がでる
        """
        sum += sqrt((i[0][0]-i[0][1])**2+(i[1][0]-i[1][1])**2)*factorial(n-1)

    # 全パスの平均
    print(sum/factorial(n))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import permutations
from math import sqrt, pow, factorial
 
def calc(a, b):
    x1, y1 = a
    x2, y2 = b
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))
 
 
n = int(input())
xy = []
for i in range(n):
	xy.append(list(map(int, input().split())))
 

ans = 0
for order in permutations(range(n)):
    tmp = 0
    for i in range(1, n):
        tmp += calc(xy[order[i]], xy[order[i - 1]])
    ans += tmp
ans /= factorial(n)
 
print(ans)
print(list(permutations((range(n)))))

Submission status: Wrong Answer

Solution code:
import math
import itertools
n = int(input())
ma = [list(map(int,input().split())) for _ in range(n)]
print(ma) 
#[[0, 0], [1, 0], [0, 1]]

li = [i for i in range(n)]
kumiawase = list(itertools.permutations(li))
#[(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]
fin_li = []
kumi_kazu = 0
for k in kumiawase:
    #print(k)
    for i,kk in enumerate(list(k)):
        if i == 0:
            continue
        start = ma[k[i]]
        goal = ma[k[i-1]]
        x = (start[0]-goal[0])**2
        y = (start[1]-goal[1])**2
        fin_li.append(math.sqrt(x+y))
    kumi_kazu += 1
#print(kumiawase)
#print(fin_li)
#print(kumiawase,kumi_kazu)
print(sum(fin_li)/kumi_kazu)

Submission status: Wrong Answer

Solution code:
import itertools
import math

def kj(k):
  if k==1:
    return 1
  else:
    return k*kj(k-1)
  return 0


n=int(input())

x=[]
y=[]

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

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

dis=0

for v in itertools.permutations(l):
  
  for i in range(n-1):
    dis+=math.sqrt(((x[i]-x[i+1])**2) + ((y[i]-y[i+1])**2) )

dis=dis/kj(n)
print(dis)

Submission status: Wrong Answer

Solution code:
n = int(input())
xy_li = [list(map(int,input().split())) for _ in range(n)]
from itertools import permutations
import math
def distance(a,b):
    return math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2)
ans = 0
cnt = 0
i_li = [i for i in range(n)]
for x in permutations(i_li,n):
    cnt += 1
    print(x)
    for i in range(n-1):
        ans += distance(xy_li[x[i]],xy_li[x[i+1]])
        
print(ans/cnt)

Submission status: Wrong Answer

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

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

print(xy)
dist = 0

for i in range(n):
    for j in range(n):
        print(i, j)
        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)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
N = int(input())
p = [list(map(int,input().split())) for _ in range(N)]
print(np.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)) / (N / 2))

Submission status: Wrong Answer

Solution code:
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 = 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)

Submission status: Wrong Answer

Solution code:
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 * (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)

Submission status: Wrong Answer

Solution code:
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

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

ans = ans / factorial(N)

print(ans)

Submission status: Wrong Answer

Solution code:
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

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

ans = ans / factorial(N)

print(ans)

Submission status: Wrong Answer

Solution code:
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())

print(x, y)

ans = 0

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

ans = ans / factorial(N)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

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

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

ans = 0

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

ans /= factorial(N)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

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

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

ans = 0

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

ans /= factorial(N)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())

x = []
y = []
sum = 0

#座標入力
for i in range(n):
	a, b = map(int, input().split())
	x.append(a)
	y.append(b)

#距離の総和
for i in range(n):
	for j in range(n):
		num = math.factorial(n-1)									
		dist = ((x[i]-x[j])^2+(y[i]-y[j])^2)**0.5
		sum+= num*dist

print(sum/math.factorial(n))

Submission status: Wrong Answer

Solution code:
# 初期入力
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_2 =[ t for t in permutations(range(N)) ]
junban =junban_2[:len(junban_2)//2] # 逆順は考えなくていい
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] ] )

        #x.append(kyori(S[i[j_i]],S[i[j_i+1]]))
        #print(x)
    y =sum(x)    
    x_sum.append(y)
    x.clear()
kotae =mean(x_sum) 

print(kotae)

Submission status: Wrong Answer

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

X.append(X[0])
Y.append(Y[0])

def length(X1, Y1, X2, Y2):
    l = (X2-X1)**2 + (Y2-Y1)**2
    return math.sqrt(l)

sum = 0
for i in range(n):
    sum += length(X[i],Y[i],X[i+1],Y[i+1])
#print(sum)
ans = sum * (2/n)
print(ans)

Submission status: Wrong Answer

Solution code:
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*(n-1)//2)
print(ans*2)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ls1 = []
ls2 = []
for i in range(N):
    ls1.append(list(map(int,input().split())))
x = 0
y = 0
for i in range(N):
    for j in range(i+1,N):
        x = (ls1[i][0]-ls1[j][0])**2
        y = (ls1[i][0]-ls1[j][0])**2
        XY = math.sqrt(x+y)
        ls2.append(XY)
if len(ls2) == 1:
    print(ls2[0])
else:
    ans = sum(ls2)*2/N
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
location = [list(map(int, input().split())) for _ in range(n)]

from itertools import permutations
import math
distance = []
for route in list(permutations(range(1,n+1))):
  route = list(route)

  dis = 0
  for i in range(0,n-1):
    d = math.sqrt(pow(location[route[i]-1][0]-location[route[i+1]-1][0],2) + pow(location[route[i]-1][1]-location[route[i+1]-1][1],2))
    dis = dis + d
  distance.append(d)
  
ans = sum(distance)/len(list(permutations(range(1,n+1))))
print(ans)

Submission status: Wrong Answer

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

s = 0
c = 0
for i in range(n):
    for k in range(i + 1, n):
        s += ((xs[i] - xs[k]) ** 2 + (ys[i] - ys[k]) ** 2) ** 0.5
        c += 1
a = s / c
for i in range(1, n):
    a *= i
print(a)

Submission status: Wrong Answer

Solution code:
import math

def calculateAvarageLength(n, t):
    # i->j 合計の長さ
    total = 0
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            s = t[i]
            e = t[j]
            length= math.sqrt((s[0] - e[0]) ** 2 + (s[1] - e[1]) **2)
            total += length
    pattern = math.factorial(n) / 2
    return total / pattern

n = int(input())
t = []
for i in range(n):
    line = input().split()
    t.append([int(line[0]), int(line[1])])

print(calculateAvarageLength(n , t))

Submission status: Wrong Answer

Solution code:
# AtCoder Beginner Contest 145
# C - Average Length
# https://atcoder.jp/contests/abc145/tasks/abc145_c
from itertools import permutations

N, *A = map(int, open(0).read().split())
X = A[0::2]
Y = A[1::2]
print(X, Y)


def distance(a, b):
    return ((X[a]-X[b])**2 + (Y[a]-Y[b])**2)**0.5


length = 0
cnt = 0
print(*[p for p in permutations(range(N))])
for P in permutations(range(N)):
    cnt += 1
    prev = P[0]
    for i in P[1:]:
        length += distance(prev, i)
        prev = i

print(length/cnt)

Submission status: Wrong Answer

Solution code:
import itertools
import math

s = int(input())
m = []
for i in range(s):
  m.append(list(map(int, input().split())))

def factorial(a):
  if (a == 1):
    return 1
  return a * (a-1)

f = factorial(s)

length = 0
p = itertools.permutations(m, r=None)
for c in p:
  l = list(c)
  for k in range(len(l) - 1):
    length += math.sqrt((l[k][0] - l[k+1][0] ) ** 2 + (l[k][1] - l[k+1][1]) ** 2)

print(length / f)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from itertools import permutations
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
order = [i for i in range(N)]
s = 0
for a in permutations(order, N):
    for b in range(N-1):
        s += sqrt((xy[a[b]][0]-xy[a[b+1]][0])**2+(xy[a[b]][1]-xy[a[b+1]][1])**2)
print(s / (N*(N-1)))

Submission status: Wrong Answer

Solution code:
import itertools
import math
n = int(input())
xy = [[int(j) for j in input().split()] for i in range(n)]
x = [i[0] for i in xy]
y = [i[1] for i in xy]
sum = 0
for i in list(itertools.permutations(range(n), n)): sum += math.sqrt((x[i[0]] - x[i[1]]) ** 2 + (y[i[0]] - y[i[1]]) ** 2)
print(sum / n)

Submission status: Wrong Answer

Solution code:
n = int(input())
X = []
Y = []
for i in range(n):
  x, y = map(int, input(). split())
  X.append(x)
  Y.append(y)
ans=0
for i in range(n-1):
  for j in range(n):
    ans+=int(( (X[j]-X[i])**2 + (Y[j]-Y[i])**2 )**(1/2))
print(2*ans//n)

Submission status: Wrong Answer

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

import math
length = 0
for i in range(N-1):
    for j in range(i+1,N):
        length = math.sqrt((X[i]-X[j])**2+(Y[i]-Y[j])**2)

M = 1
for i in range(1,N+1):
    M *= i
C = N*(N-1)/2

print(M*(N-1)*length/2/C)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N-1):
    for j in range(i+1,N):
            ans_sum+=math.sqrt((x[j]-x[i])**2+(y[j]-y[i])**2)
print(ans_sum/N)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N-1):
    for j in range(i+1,N):
        if i!=j:
            ans_sum+=math.sqrt((x[j]-x[i])**2+(y[j]-y[i])**2)
print(ans_sum*(N-1)/math.factorial(N))

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        if i!=j:
            ans_sum+=math.sqrt((x[j]-x[i])**2+(y[j]-y[i])**2)**0.5
print(ans_sum/N)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        if i!=j:
            ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5
print(ans_sum/N)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        if i!=j:
            ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans_sum*0.5/N)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        if i!=j:
            ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans_sum*(N-1)/N)

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        if i!=j:
            ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans_sum*(N-1)/math.factorial(N))

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        if i!=j:
            ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans_sum*2/math.factorial(N))

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans_sum*2/math.factorial(N))

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
x=[0]*N
y=[0]*N
for i in range(N):
    x[i],y[i]=map(int,input().split())
ans_sum=0
for i in range(N):
    for j in range(N):
        ans_sum+=math.sqrt((x[i]-x[j])**2+(y[i]-y[j])**2)
print(ans_sum/math.factorial(N))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 

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

    ans = [0]
    p = 1
    for i in range(N):
        p *= i+1
    print(p)
    def dfs(d, perm):
        if d==N:
            dist = 0
            for i in range(N-1):
                dist += ((xy[perm[i+1]][0]-xy[perm[i]][0])**2+(xy[perm[i+1]][1]-xy[perm[i]][1])**2)**0.5
            ans[0] += dist
        else:
            for i in range(N):
                if i not in perm:
                    dfs(d+1, perm+[i])

    dfs(0, [])
    print(ans[0]/p)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import itertools

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

x = 0
y = 1
d = 0

for p in itertools.permutations(range(n)):
    p = list(p)
    for i in range(n-1):
        d += ((xy[p[i]][x] - xy[p[i+1]][x])**2 - (xy[p[i]][y] - xy[p[i+1]][y])**2)**0.5
        # print(d)

print(d/math.factorial(n))

Submission status: Wrong Answer

Solution code:
import math
import itertools

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

x = 0
y = 1
d = 0

for p in itertools.permutations(range(n)):
    p = list(p)
    for i in range(n-1):
        d += ((xy[p[i]][x] - xy[p[i+1]][x])**2 - (xy[p[i]][y] - xy[p[i+1]][y])**2)**0.5
        print(d)

print(d/math.factorial(n))

Submission status: Wrong Answer

Solution code:
import itertools
import math

N = int(input())
x = [0]*N
y = [0]*N
for i in range(N):
    x[i], y[i] = map(int, input().split())
    
a = list(itertools.permutations([i for i in range(1, N+1)]))

n = math.factorial(N)

road = 0
for i in range(n-1):
    for j in range(N):
        road += math.sqrt((x[a[i][j]-1]-x[a[i+1][j]-1])**2+(y[a[i][j]-1]-y[a[i+1][j]-1])**2)
        
print(road/n)

Submission status: Wrong Answer

Solution code:
import math
def distance(x1,x2,y1,y2):
  d=math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d
count=int(input())
zahyou=[]
for i in range(count):
  a=input().split(" ")
  zahyou.append(a)

lenth=0
for i in zahyou:
  for j in zahyou:
    lenth=lenth+distance(int(i[0]),int(j[0]),int(i[1]),int(j[1]))
print(lenth//math.factorial(count))

Submission status: Wrong Answer

Solution code:
import math
import itertools
from decimal import Decimal
N = int(input())
z = []
A = []
for i in range(N):
  xy = list(map(int,input().split()))
  z.append(xy)
for j in range(N):
  for k in range(j+1,N):
    A.append(Decimal(math.sqrt((z[j][0]-z[k][0])**2+(z[j][1]-z[k][1])**2)))
B = list(itertools.permutations(A, N-1))
if len(B) == 0:
  print(A[0])
  exit()
for l in range(len(B)):
  B[l] = sum(B[l])
print(sum(B)/math.factorial(N))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

N = int(input())

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

gokei = 0
for i in range(N):
    for j in range(i+1, N):
        gokei += np.linalg.norm(X[i]-X[j])
        print(gokei)
if N == 2:
    A = 2
else:
    A = math.factorial(N-2)*4
print(gokei*A/math.factorial(N))

Submission status: Wrong Answer

Solution code:

import itertools

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

route = list(itertools.combinations(P, 2))
print(route)

for i in route:

   S += ((i[0][0] - i[1][0])**2 + (i[0][1] - i[1][1])**2)**0.5

print(S*2/N)

Submission status: Wrong Answer

Solution code:
# 14　Square869120Contest #4 B - Buildings are Colorful!
import itertools
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in itertools.permutations(range(n)):
    for j in range(len(i)-1):
        ans += pow(pow(xy[i[j]][0]-xy[i[j+1]][0], 2) + pow(xy[i[j]][1]-xy[i[j+1]][1], 2), 0.5)
print(ans/(2*n))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range (n)]

a=0

for i in range (n):
  for j in range (n):
    a+=((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**(1/2)
    
print (a*2/n)

Submission status: Wrong Answer

Solution code:
import math
n = input()
def fact(nu):
    res = 1
    for i in xrange(1,nu+1)        :
        res*= i
    return res

def sqr(a,b):
    res = (float(a[0])-b[0])**2 + (float(a[1])-b[1])**2
    return res


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

Submission status: Wrong Answer

Solution code:
import math
import copy


def path(cities, xi, yi):
    if not cities:
        return 0

    sum = 0
    for j, city in enumerate(cities):
        xj, yj = city
        d = math.sqrt((xi - xj) ** 2 + (yi - yj) ** 2)
        cs = copy.deepcopy(cities)
        cs.pop(j)
        sum += d + path(cs, xj, yj)

    return sum


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

sum = 0
for i in range(n):
    aa = copy.deepcopy(a)
    aa.pop(i)
    sum += path(aa, a[i][0], a[i][1])

print(sum / math.factorial(n))

Submission status: Wrong Answer

Solution code:
import math

N=int(input())
X=[]
Y=[]
for i in range(N):
	x,y=map(int,input().split())
	X.append(x)
	Y.append(y)
L=[]
for i in range(N-1):
	for j in range(i,N):
		l=math.sqrt(((X[i]-X[j])**2)+((Y[i]-Y[j])**2))
		L.append(l)
ans=sum(L)*(math.factorial(N-1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
xy=[list(map(int,input().split())) for i in range(n)]

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
XY = [tuple(map(int,input().split())) for i in range(n)]
for jun in itertools.permutations(range(n),n):
  cost = 0
  for i in range(1,n):
    cost += math.sqrt((XY[jun[i]][0]-XY[jun[i]-1][0])**2+(XY[jun[i]][1]-XY[jun[i]-1][1])**2)
  ans += cost
print(ans/math.factorial(n))