题解 | #Freckles#
Freckles
https://www.nowcoder.com/practice/41b14b4cd0e5448fb071743e504063cf
from math import sqrt def dis(x,y): return sqrt((x[0]-y[0])**2+(x[1]-y[1])**2) a=[] dist=[] res=0 c=input() for i in range(int(c)): x,y = input().split() a.append([float(x),float(y)]) dist.append(a.pop()) while(len(a)!=0): dd=[] for i in a: for j in dist: dd.append([dis(i,j),i,j]) dd.sort() res+=dd[0][0] a.remove(dd[0][1]) dist.append(dd[0][1]) print("%.2f" %res)