链接

需要特判一下n=1的时候

精度调太低会超时

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 310
#define LL long long
#define INF 1e8
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct point
{
double x,y;
double vx,vy;
}p[N],pp[N];
int n;
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double calc(double tt)
{
int i,j;
for(i = ; i <= n; i++)
{
pp[i].x=p[i].x+tt*p[i].vx;
pp[i].y=p[i].y+tt*p[i].vy;
}
double ans = 0.0;
for(i = ; i <= n; i++)
{
for(j = ; j <= n ;j++)
ans = max(ans,dis(pp[i],pp[j]));
}
return ans;
}
void solve(int k)
{
double M,RM;
double L = 0.0;
double R = INF;
while (L + eps < R)
{
M = (L + R) / ;
RM = (M + R) / ;
double s1 = calc(M);
double s2 = calc(RM);
if ( s1 < s2 ) R = RM;
else L = M;
}
printf("Case #%d: ",k);
printf("%.2f %.2f\n",R,calc(R));
}
int main()
{
int t,i;
int kk = ;
cin>>t;
while(t--)
{
scanf("%d",&n);
for(i = ; i <= n ;i++)
scanf("%lf%lf%lf%lf",&p[i].x,&p[i].y,&p[i].vx,&p[i].vy);
if(n==)
{
printf("0.00 0.00\n");
continue;
}
solve(++kk);
}
return ;
}

hdu4717The Moving Points(三分)的更多相关文章

  1. HDU 4717 The Moving Points(三分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...

  2. HDU 4717The Moving Points warmup2 1002题(三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  3. HDU 4717 The Moving Points (三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  4. HDUOJ---The Moving Points

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  5. HDU-4717 The Moving Points(凸函数求极值)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  6. HDOJ 4717 The Moving Points

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  7. The Moving Points hdu4717

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  8. F. Moving Points 解析(思維、離散化、BIT、前綴和)

    Codeforce 1311 F. Moving Points 解析(思維.離散化.BIT.前綴和) 今天我們來看看CF1311F 題目連結 題目 略,請直接看原題. 前言 最近寫1900的題目更容易 ...

  9. hdu 4717 The Moving Points(第一个三分题)

    http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小 ...

随机推荐

  1. PHP上传文件详解 错误提示

    首先在php.ini里配置上载文件.有以下几个重要的配置单: 选项 默认值 说明 post_max_size 8M 控制以后的POST请求的最大规模.必须大于upload_max_filesize选项 ...

  2. Andriod 字符串数组里加入字符串元素

    private String[] t1 = { "姓名", "性别", "年龄", "居住地","邮箱&quo ...

  3. In Action(SPFA+01背包)

    In Action Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  4. 验证码识别--type7

    验证码识别--type7 一.干扰分析 有黑色边框,然后点干扰,线干扰 去边框 去点干扰 变成这样的结果,方便运算吗?也可以多种方式联合起来运算的.我相信在很多情况下,都可能会遇到类似的结果.我们人类 ...

  5. 如何快捷输入函数上方的注释代码(Summary)

    写完类或函数(注意必须写完,不然出现的信息会不完整)后,在其上方空行输入/**,然后回车,就可以为其添加Summary.    

  6. Codeforces Round #373 (Div. 2) B

    Description Anatoly lives in the university dorm as many other students do. As you know, cockroaches ...

  7. php修改和增加xml结点属性

    <?xml version="1.0" encoding="UTF-8" ?> <clientSet> <server url=& ...

  8. Storm系列之三——Fault Tolerance

    本文介绍Storm容错的设计细节. 1.当一个worker进程死了会发生什么? 当worker死了,supervisor会重启它.如果它尝试开启多次失败并且不能与nimbus发送心跳,Nimbus会重 ...

  9. pt-query-digest怎么分析慢查询日志分析数据

    在进行使用linux系统作为服务器的情况,那几需要进行对linux的服务器进行性能上数据进行抓取之后,就需要对数据中内容进行分析,看数据库中内容是否存在瓶颈上的问题,在进行获取到的数据的慢查日志,将使 ...

  10. C#其他

    1.switch - if ...else if...switch(表达式) { case 值: ..... break; case 值: ..... break; default: ..... br ...