zoukankan      html  css  js  c++  java
  • Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi

    题目链接:

    http://codeforces.com/contest/706/problem/A

    Description

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

    </big>
    
    
     
    
    
    
    
    ##Input
    <big>
    

    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.

    </big>
    
    
    
    
    
    
    ##Output
    <big>
    

    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.

    </big>
    
    
     
     
    ##Examples
    <big>
    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
    </big>
    
    
    ##Source
    <big>
    Codeforces Round #367 (Div. 2)
    </big>
    
    
    
    
    <br/>
    ##题意:
    <big>
    求从(a,b)到任一一点的最短时间.
    </big>
    
    
    <br/>
    ##题解:
    <big>
    直接对所有点求一次时间即可.
    </big>
    
    
    
    
    <br/>
    ##代码:
    ``` cpp
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <algorithm>
    #include <queue>
    #include <map>
    #include <set>
    #include <stack>
    #include <vector>
    #include <list>
    #define LL long long
    #define eps 1e-8
    #define maxn 101000
    #define mod 100000007
    #define inf 0x3f3f3f3f
    #define mid(a,b) ((a+b)>>1)
    #define IN freopen("in.txt","r",stdin);
    using namespace std;
    
    double x,y;
    
    int main(int argc, char const *argv[])
    {
        //IN;
    
        while(scanf("%lf %lf", &x,&y) != EOF)
        {
            int n; cin >> n;
            double ans = inf;
            for(int i=1; i<=n; i++) {
                double xx,yy,v; cin >> xx >> yy >> v;
                double cur = sqrt((xx-x)*(xx-x)+(yy-y)*(yy-y)) / v;
                ans = min(ans, cur);
            }
    
            printf("%f
    ", ans);
        }
    
        return 0;
    }
    
  • 相关阅读:
    jQuery里的$.ajax()方法详解
    express框架使用axios进行post请求, 两次请求问题
    electron-vue 报错 Unresolved node modules: bufferutil, utf-8-validate, canvas
    electron-vue离线打包
    个推技术:性能提升60%↑ 成本降低50%↓ Spark性能调优看这篇就够了!
    百亿级日志流分析实践 | 剖析个推后效分析功能实现原理
    iOS开发常用国外网站清单
    一篇文章搞定Git——Git代码管理及使用规范
    音视频技术入门——音频处理
    Java内存空间知识点梳理
  • 原文地址:https://www.cnblogs.com/Sunshine-tcf/p/5793552.html
Copyright © 2011-2022 走看看