CSP-称检测点查询Python实现

编程入门 行业动态 更新时间:2024-10-26 20:27:26

<a href=https://www.elefans.com/category/jswz/34/1770139.html style=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实现

本文发布于:2023-07-28 18:44:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1278180.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:CSP   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!