题解归档 - cf706A

题解归档 - cf706A

本文由 cf-code 本地题解库自动归档;公开内容以本地 AC/验证版本为准。

思路

cf706A — Beru-taxi

题意

Vasiliy 在 (a,b),有 n 辆出租车在 (xi,yi),速度 vi。每辆车直线全速驶来,求他坐上任意一辆的最短时间。

做法

对每辆车算 dist = sqrt((a-xi)^2+(b-yi)^2),时间 dist/vi,取最小值。

结论

签到几何;注意 fixed<<setprecision(9) 输出。

代码

来源:problems/cf706A/solution.cpp

/* Author: likely
 * Time: 2026-06-08 04:00:43
**/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,n,i,x,y,v;
double ans,cur,dx,dy;
int main(){
    cin>>a>>b>>n;
    ans=1e18;
    for(i=1;i<=n;i++){
        cin>>x>>y>>v;
        dx=a-x;
        dy=b-y;
        cur=sqrt(dx*dx+dy*dy)/v;
        if(cur<ans) ans=cur;
    }
    cout<<fixed<<setprecision(9)<<ans<<endl;
    return 0;
}
~  ~  The   End  ~  ~


 赏 
感谢您的支持,我会继续努力哒!
支付宝收款码
tips
文章二维码 分类标签:归档TypechoAutoUpload
文章标题:题解归档 - cf706A
文章链接:https://www.fangshaonian.cn/archives/372/
最后编辑:2026 年 6 月 28 日 19:08 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
(*) 6 + 6 =
快来做第一个评论的人吧~