链接

需要特判一下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. [BIM]BIM中IDM介绍

    参考:http://blog.fang.com/25866228/10613454/articledetail.htm IDM的全称是Information Delivery Manual,信息交付手 ...

  2. 【转】MYSQL入门学习之一:基本操作

    转载地址:http://www.2cto.com/database/201212/173868.html 1.登录数据库    www.2cto.com       命令:mysql -u usern ...

  3. easyui的页面等待提示层,即mask

    /* * 使用方法: * 开启:MaskUtil.mask(); * 关闭:MaskUtil.unmask(); * * MaskUtil.mask('其它提示文字...'); */ var Mask ...

  4. asp.net 查询,导出

    using System;using System.Configuration;using System.Data;using System.Linq;using System.Web;using S ...

  5. 记一次SortedDictionary的不当使用

    起初想用SortedDictionary做游戏中的排行榜,代码如下: using UnityEngine; using System; using System.Collections; using ...

  6. laravel 重写以及500错误

    http://www.golaravel.com/laravel/docs/5.1/ sudo chmod 755 -R laravel chmod -R o+w laravel/storage

  7. Android 编程下Touch 事件的分发和消费机制

    1.事件分发:public boolean dispatchTouchEvent(MotionEvent ev) Touch 事件发生时 Activity 的 dispatchTouchEvent(M ...

  8. 编写一个JAVA小程序取得IP地址

    在TCP/IP 互联网时,经常会需要查询自己主机的IP地址和www服务器的IP地址.虽然,我们可以使用IPCONFIG 和PING 进行IP地址查询,但是如果在应用程序或APPLET中使用此命令会破坏 ...

  9. 在Struts2中配置Action

    在Struts2中配置Action <package>: 1.定义Action使用<package>标签下的<action>标签完成,一个<package&g ...

  10. Linux 性能监测:介绍

    看了某某教程.读了某某手册,按照要求改改某某设置.系统设定.内核参数就认为做到系统优化的想法很傻很天真:)系统优化是一项复杂.繁琐.长期的 工作,优化前需要监测.采集.测试.评估,优化后也需要测试.采 ...