CodeForces 706A Beru-taxi
2016-08-12 09:20
281 查看
A. Beru-taxi
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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.
Output
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
.
Examples
input
output
input
output
Note
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家的坐标,和m个出租车的坐标以及速度,求出租车到Vasiliy家的最小时间
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Input
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.
Output
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
.
Examples
input
0 0 2 2 0 1 0 2 2
output
1.00000000000000000000
input
1 3 3 3 3 2 -2 3 6 -2 7 10
output
0.50000000000000000000
Note
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家的坐标,和m个出租车的坐标以及速度,求出租车到Vasiliy家的最小时间
#include<stdio.h> #include<math.h> #include<string.h> #include<algorithm> #define INF 0xfffffff using namespace std; double dis(double x1,double y1,double x2,double y2) { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } int main() { int n,i,j; double x,y,a,b,v1,t,d; while(scanf("%lf%lf",&x,&y)!=EOF) { double Min=INF; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%lf%lf%lf",&a,&b,&v1); d=dis(x,y,a,b); t=d/v1; if(t<Min) Min=t; } printf("%lf\n",Min); } return 0; }
相关文章推荐
- codeforces 706A Beru-taxi
- CodeForces 706A Beru-taxi (数学计算,水题)
- CodeForces 706A Beru-taxi
- CodeForces 158 B. Taxi(模拟)
- Codeforces contest 883 problem L. Berland.Taxi(Treap+优先队列)
- codeforces-158B-Taxi题解
- 【模拟】Codeforces 706A Beru-taxi
- Problem--158B--Codeforces--Taxi
- codeforces 706A A. Beru-taxi
- codeforces 158B Taxi (贪心)
- codeforces 158B - Taxi
- 【模拟】Codeforces 706A Beru-taxi
- CodeForces 158 B. Taxi(模拟)
- Codeforces 158B - Taxi
- codeforces 158B(Taxi) Java
- codeforces 706A A. Beru-taxi(水题)
- codeforces-367#A. Beru-taxi
- 【codeforces】B. Taxi
- CodeForces-706A.Beru-taxi
- Codeforces 488C Fight the Monster