CUC-SUMMER-10-B

B - Beru-taxi
Codeforces Round #367 (Div. 2)

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

.

Example
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.


题意:你在一个起始坐标想打车,每辆车有一个自己的坐标和速度,那辆车来的最快

解法:距离除以速度

代码:

#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int a,b;
    bool flag=0;
    vector<int> v;
    scanf("%d%d",&a,&b);
    v.push_back(b);
    while(1){
        if(a==b){
            flag=1;
            break;
        }
        if(b<a)
            break;
        if(b%2==0){
            b/=2;
            v.push_back(b);
        }
        else if(b%10==1){
            b=(b-1)/10;
            v.push_back(b);
        }
        else
            break;
    }
    if(!flag)
        printf("NO\n");
    else{
        printf("YES\n%d\n",v.size());
        for(int i=v.size()-1;i>=0;i--){
            if(i!=v.size()-1)
                printf(" ");
            printf("%d",v[i]);
        }
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容