AtCoder Beginner Contest 145 C – Average Length

AtCoderなど過去問

AtCoder Beginner Contest 145 C – Average Length

import itertools
import math

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

dist = 0
for cnt, i in enumerate(itertools.permutations(plot)):
    x,y = i[0]
    for j in i:
        dist += math.sqrt((x-j[0])**2 + (y-j[1])**2)
        x,y = j[0],j[1]
     
print(dist/(cnt+1))

コメント

タイトルとURLをコピーしました