Codeforces Round #367 (Div. 2)ABeru-taxi

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 xiyi and vi ( - 100 ≤ xi, yi ≤ 1001 ≤ 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.

一个人在家(a,b),附近有n个出租车,坐标分别为(xi,yi);速度为v,求这个人能坐上出租车的最短时间。

代码如下:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
struct node{
	double x,y,t;
}arr[1100];
bool cmp(node a,node b)
{
	return a.t<b.t;
}
int main()
{
	int a,b,n,v;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		scanf("%d",&n);
		int i;
		for(i=0;i<n;i++)
		{
			scanf("%lf%lf%d",&arr[i].x,&arr[i].y,&v);
			arr[i].t=sqrt((arr[i].x-a)*(arr[i].x-a)+(arr[i].y-b)*(arr[i].y-b))/v*1.0;
		}
		sort(arr,arr+n,cmp);
		printf("%lf\n",arr[0].t);
	}
} 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值