题解归档 - cf706A
本文最后由方少年更新于2026 年 6 月 28 日,已超过0天没有更新。如果文章内容或图片资源失效,请留言反馈,将会及时处理,谢谢!
题解归档 - cf706A
本文由 cf-code 本地题解库自动归档;公开内容以本地 AC/验证版本为准。
- 本地编号:
cf706A - 本地来源:
problems/cf706A/idea.md - 题目链接:https://codeforces.com/contest/706/problem/A
- 原始标题:cf706A — Beru-taxi
思路
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 ~ ~
文章标题:题解归档 - cf706A
文章链接:https://www.fangshaonian.cn/archives/372/
最后编辑:2026 年 6 月 28 日 19:08 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)