codeforces 706A A. Beru-taxi(水题)

题目链接:

A. Beru-taxi

题意:

问那个taxi到他的时间最短,水题;

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack>
#include <map>

using namespace std;

#define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss));

typedef  long long LL;

template<class T> void read(T&num) {
    char CH; bool F=false;
    for(CH=getchar();CH<‘0‘||CH>‘9‘;F= CH==‘-‘,CH=getchar());
    for(num=0;CH>=‘0‘&&CH<=‘9‘;num=num*10+CH-‘0‘,CH=getchar());
    F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
    if(!p) { puts("0"); return; }
    while(p) stk[++ tp] = p%10, p/=10;
    while(tp) putchar(stk[tp--] + ‘0‘);
    putchar(‘\n‘);
}

const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e18;
const int N=1e5+10;
const int maxn=5e3+4;
const double eps=1e-12;

int n;
double a,b,x[maxn],y[maxn];
double getdis(double fx,double fy,double fa,double fb)
{
    return sqrt((fx-fa)*(fx-fa)+(fb-fy)*(fb-fy));
}
int main()
{
    scanf("%lf%lf",&a,&b);
   read(n);
   double ans=inf,v;
   For(i,1,n)
   {
        scanf("%lf%lf%lf",&x[i],&y[i],&v);
        ans=min(ans,getdis(a,b,x[i],y[i])/v);
   }
   printf("%.10lf\n",ans);
    return 0;
}

  

时间: 2024-08-02 15:41:57

codeforces 706A A. Beru-taxi(水题)的相关文章

CodeForces 707A Brain&#39;s Photos (水题)

题意:给一张照片的像素,让你来确定是黑白的还是彩色的. 析:很简单么,如果有一种颜色不是黑白灰,那么就一定是彩色的. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #i

codeforces 710A A. King Moves(水题)

题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include &l

codeforces 696A Lorenzo Von Matterhorn 水题

这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽量不用 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #

CodeForces 589I Lottery (暴力,水题)

题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cma

CodeForces 518A Vitaly and Strings (水题,字符串)

题意:给定两个相同长度的字符串,让你找出一个字符串,字典序在两都之间. 析:这个题当时WA了好多次,后来才发现是这么水,我们只要把 s 串加上,然后和算数一样,该进位进位,然后再和 t 比较就行. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <set> #include <cstring> #in

Codeforces gym 100685 C. Cinderella 水题

C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C Description Cinderella is given a task by her Stepmother before she is allowed to go to the Ball. There are N (1 ≤ N ≤ 1000) bottles with water in th

CodeForces 709C Letters Cyclic Shift (水题)

题意:给定一个字符串,让你把它的一个子串字符都减1,使得总字符串字典序最小. 析:由于这个题是必须要有一个字串,所以你就要注意这个只有一个字符a的情况,其他的就从开始减 1,如果碰到a了就不减了,如果到最后一位了还没开始减, 就减最后一位. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <c

Codeforces GYM 100114 B. Island 水题

B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description On February 30th this year astronauts from the International Space Station flew over the Pacific Ocean and took a picture, on which was discovered a pr

CodeForces 712B Memory and Trident (水题,暴力)

题意:给定一个序列表示飞机要向哪个方向飞一个单位,让你改最少的方向,使得回到原点. 析:一个很简单的题,把最后的位置记录一下,然后要改的就是横坐标和纵坐标绝对值之和的一半. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath>

CodeForces 719B Anatoly and Cockroaches (水题贪心)

题意:给定一个序列,让你用最少的操作把它变成交替的,操作有两种,任意交换两种,再就是把一种变成另一种. 析:贪心,策略是分别从br开始和rb开始然后取最优,先交换,交换是最优的,不行再变色. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <c