CSP-称检测点查询Python实现"/>
CSP-称检测点查询Python实现
n,X,Y = map(int,input().split())
# 存放每个检测点到人的距离
distance = []
# 存放结果集
result = []
for i in range(n):x,y = map(int,input().split())# 计算的是距离的平方d = (x-X)**2 + (y-Y)**2distance.append(d)
for i in range(3):# 获得距离最小的值的下标ind = distance.index(min(distance))# 将下标+1 存入结果集,因为下标是从0开始的result.append(ind+1)# 将该位置的距离设为100000(尽可能大点,因为我们算距离的时候没有开根号),这样下次找最小值就不会找该位置了distance[ind] = 100000
for i in result:print(i)
更多推荐
CSP-称检测点查询Python实现
发布评论