codeforces706A之Beru-taxi
来源:互联网 发布:java项目相对路径 编辑:程序博客网 时间:2024/06/05 20:41
Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is located at point (xi, yi) and moves with a speed vi.
Consider that each of n drivers will move directly to Vasiliy and with a maximum possible speed. Compute the minimum time when Vasiliy will get in any of Beru-taxi cars.
The first line of the input contains two integers a and b ( - 100 ≤ a, b ≤ 100) — coordinates of Vasiliy's home.
The second line contains a single integer n (1 ≤ n ≤ 1000) — the number of available Beru-taxi cars nearby.
The i-th of the following n lines contains three integers xi, yi and vi ( - 100 ≤ xi, yi ≤ 100, 1 ≤ vi ≤ 100) — the coordinates of the i-th car and its speed.
It's allowed that several cars are located at the same point. Also, cars may be located at exactly the same point where Vasiliy lives.
Print a single real value — the minimum time Vasiliy needs to get in any of the Beru-taxi cars. You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.
Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .
0 022 0 10 2 2
1.00000000000000000000
1 333 3 2-2 3 6-2 7 10
0.50000000000000000000
In the first sample, first taxi will get to Vasiliy in time 2, and second will do this in time 1, therefore 1 is the answer.
In the second sample, cars 2 and 3 will arrive simultaneously.
题意:给出Vasiliy家的坐标(a,b),Vasiliy急着去上班,他手机软件检测到附近有n辆出租车,坐标(xi,yi),速度vi,问最快到达他家的车所花时间为多少????
sb题!!!!
AC代码如下:
#include <iostream>#include<cstdio>#include<cmath>//#define mini 0xfffffff using namespace std; double x[3000],y[3000],v[3000];double fun(int a,int b,int x,int y,int v){return (double)sqrt((a-x)*(a-x)+(b-y)*(b-y))/v;}int main(int argc, char** argv) {int a,b;int n,i,j;while(cin>>a>>b){cin>>n;double min=999999;for(i=0;i<n;i++) {cin>>x[i]>>y[i]>>v[i];if(fun(a,b,x[i],y[i],v[i])<min){min=fun(a,b,x[i],y[i],v[i]);}}printf("%.20lf\n",min);}return 0;}
- codeforces706A之Beru-taxi
- A. Beru-taxi
- CodeForces 706A Beru-taxi
- 【codeforces 706A Beru-taxi】
- CodeForces-706A.Beru-taxi
- codeforces-367#A. Beru-taxi
- codeforces 706A Beru-taxi
- codeforces 706A A. Beru-taxi
- 【模拟】Codeforces 706A Beru-taxi
- CodeForces 706A Beru-taxi 【水题】
- 【Codeforces Round 367 (Div 2) A】【水题】Beru-taxi
- Codeforces Round #367 (Div. 2) A. Beru-taxi
- Codeforces Round #367 (Div. 2) A. Beru-taxi(很水)
- Taxi
- Taxi
- 讨厌taxi
- B. Taxi
- Taxi Fare
- MapReduce实现大矩阵乘法
- preference_persistent属性
- 责任链模式
- C++ int和string相互转换
- UNIX常用命令
- codeforces706A之Beru-taxi
- 一些常见错误
- maven学习——搭建Maven环境
- 148. Sort List
- 动态建树之——寻找前缀是否是其他字符串
- SVN文件状态解析
- 8.16总结
- Scala隐式( implicit)编程彻底实战之编程进阶(7)
- PASCAL Annotation转换为VOC xml格式数据