【精选】Python入门算法题(三)

今天无意中发现一道算法题很有意思,题不难,都是初中的知识,主要就是求一个固定点到一条直线的最短距离,我用了一个非常麻烦的方法才求出,我先是用余弦定理求出夹角再判断用勾股定理结合方程组解出来,很是麻烦,还画了几张图,我就问我以为朋友,他说很简单啊,拿线上两点就求出来了线的斜率然后结合点到直线距离公式就出来了。

可能我描述的不是很清楚,先来看一下题:

Brio got his house constructed near the National Highway. The Construction and Planning Committee has planned to construct a road near his house. Brio is worried about the Committee's plan as he fears that his house might come on the way of the road being constructed. In such a case, he needs to request the Committee members to replan the construction. Assume that Brio's house is a circle with center at (0,0) and radius r. Given 2 integral points (x1,y1) and (x2,y2) through which the road passes you need to give output as 
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

幽蓝丶流月

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值