http://acm.hdu.edu.cn/showproblem.php?pid=4717

【题意】:

给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小值的时刻

【题解】:

两个点为例,任意两个点,按照自己的方向移动,一般情况下是,先两点慢慢接近,直到最近距离,然后慢慢远离,后面越来越远,图像画出来有点像抛物线,

这题就是抛物线求最小值,三分:先二分时间,按照斜率确定移动方向,直到移动到抛物线的最低端

注意题目精度,每次最好分1e-5以上,才能保证正确性

【code】:

 #include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
//using namespace std; #define N 310
#define INF 1e15
#define exp 1e-6 int n; struct Nod
{
double x,y;
int dx,dy;
}node[N]; double distance(int i,int j,double k)
{
return sqrt((double)((node[i].x+k*node[i].dx-node[j].x-k*node[j].dx)*(node[i].x+k*node[i].dx-node[j].x-k*node[j].dx)
+(node[i].y+k*node[i].dy-node[j].y-k*node[j].dy)*(node[i].y+k*node[i].dy-node[j].y-k*node[j].dy)));
} double getLargest(double k)
{
int i,j;
double maks = -,temp;
for(i=;i<n;i++)
{
for(j=i+;j<n;j++)
{
temp = distance(i,j,k);
if(maks<temp)
{
maks = temp;
}
}
}
return maks;
} void sanfen()
{
double l=,mid,r=1e8,t=INF,ans=INF;
while(l<r)
{
mid = (l+r)/; //二分时间
double temp1 = getLargest(mid);
double temp2 = getLargest(mid-exp);
//printf("%lf %lf\n",temp1,temp2);
if(temp1<temp2)
{
l=mid+exp;
}
else
{
r=mid-exp;
}
if(ans>temp1)
{
ans=temp1;
t=mid;
}
}
printf("%.2lf %.2lf\n",t,ans);
} int main()
{
int t,cas=;
scanf("%d",&t);
while(t--)
{
int i;
scanf("%d",&n);
for(i=;i<n;i++)
{
scanf("%lf%lf%d%d",&node[i].x,&node[i].y,&node[i].dx,&node[i].dy);
}
printf("Case #%d: ",cas++);
sanfen();
}
return ;
}

hdu 4717 The Moving Points(第一个三分题)的更多相关文章

  1. HDU 4717 The Moving Points (三分)

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

  2. hdu 4717 The Moving Points(三分+计算几何)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y ...

  3. hdu 4717 The Moving Points(三分)

    http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距 ...

  4. HDU 4717 The Moving Points(三分)

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

  5. hdu 4717: The Moving Points 【三分】

    题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(m ...

  6. HDU 4717 The Moving Points(三分法)(2013 ACM/ICPC Asia Regional Online ―― Warmup2)

    Description There are N points in total. Every point moves in certain direction and certain speed. W ...

  7. HDU 4717 The Moving Points (三分法)

    题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream& ...

  8. HDOJ 4717 The Moving Points

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

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

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

随机推荐

  1. 控制器view的延迟加载

  2. javascript基础知识--函数定义

    函数声明式 function funname( 参数 ){ ...执行的代码 } 声明式的函数并不会马上执行,需要我们调用才会执行:funname(); * 分号是用来分隔可执行JavaScript语 ...

  3. http keepalive

    转载自: http://www.92csz.com/17/1152.html http keepalive 在http早期 ,每个http请求都要求打开一个tpc socket连接,并且使用一次之后就 ...

  4. Jersey(1.19.1) - JSON Support

    Jersey JSON support comes as a set of JAX-RS MessageBodyReader<T> and MessageBodyWriter<T&g ...

  5. 229. Majority Element II My Submissions Question

    Total Accepted: 23103 Total Submissions: 91679 Difficulty: Medium Given an integer array of size n, ...

  6. Python Quick Start

    1.安装Python 官网下载python: https://www.python.org/ 有2.x 3.x版本, 注意,python3.0不向下兼容2.x版本,有很多包3.0不提供 下载完后直接点 ...

  7. APC -- Asynchronous Procedure Call 异步过程调用

    异步过程调用(APC -- Asynchronous Procedure Call )是一种与常用的和简单的同步对象不同的一种同步机制. 我们在我们线程里使用基本的同步对象如MUTEX去通知其它线程, ...

  8. ASP.NET WEB API 初探

    本文初步介绍如何简单创建一个ASP.NET Web Api 程序. Web Api 顾名思义就是一个Api接口,客户端可调用此接口进行业务操作.此类应用与 ASP.NET  web服务(即使用扩展名. ...

  9. javascript 笔记——setTimeout的参数问题

    setTimeout("xxx",500) 双引号中的作用域不捕捉局部变量,因此会报错误 如果你需要在双引号中可以在外部定义一个变量 var now; window.onload ...

  10. Spring boot 1.3.5 RELEASE 官方文档中文翻译--Part2:新手入门

    Part II. 新手入门 如果你刚刚开始学习Spring boot或"普通"的Spring,这部分非常适合你!在这里,我们回答了最基础的"什么是?".&quo ...