0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ABC145 C - Average Length を解いた

Posted at

abc145_1.png
abc145_2.png
abc145_3.png

N が max 8 と小さいから
floating で平均を求めても問題ないのでは?
以下で通った。

abc145c.py
N = int(input())
lis = []

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

from itertools import permutations
cnt = 0
score = 0
for num in permutations(range(N),N):
    cnt += 1
    num = list(num)
    #print(num)
    for i in range(N-1):
        #print(lis[num[i]], lis[num[i+1]])
        x = lis[num[i]][0]-lis[num[i+1]][0]
        y = lis[num[i]][1]-lis[num[i+1]][1]
        score += (x**2 + y**2)**(0.5)
        #print(score)
    #print()

print("{:.6f}".format(score/cnt))

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?