HDU 4717 The Moving Points(三分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717
题意:给出n个点的坐标和运动速度(包括方向)。求一个时刻t使得该时刻时任意两点距离最大值最小。
思路:每两个点之间的距离随时间的变化是一个开口向上的抛物线。把所有的抛物线画出来。然后每个时刻取最大值。发现这个最大值是单峰函数。
struct point
{
double x,y;
void get()
{
RD(x,y);
}
point(){}
point(double _x,double _y)
{
x=_x;
y=_y;
}
point operator+(point a)
{
return point(x+a.x,y+a.y);
}
point operator-(point a)
{
return point(x-a.x,y-a.y);
}
point operator*(double a)
{
return point(x*a,y*a);
}
double len()
{
return sqrt(x*x+y*y);
}
};
point s[N],d[N];
int n;
double cal(double t)
{
point p[N];
int i;
FOR1(i,n) p[i]=s[i]+d[i]*t;
double ans=0;
int j;
FOR1(i,n) FOR(j,i+1,n) upMax(ans,(p[i]-p[j]).len());
return ans;
}
double cal()
{
double L=0,R=1e8,M1,M2;
while(R-L>EPS)
{
M1=(L+R)/2;
M2=(M1+R)/2;
if(cal(M1)<cal(M2)) R=M2;
else L=M1;
}
return L;
}
int main()
{
int num=0;
rush()
{
RD(n);
int i;
FOR1(i,n) s[i].get(),d[i].get();
if(n==1)
{
printf("Case #%d: 0.00 0.00\n",++num);
continue;
}
double t=cal();
printf("Case #%d: %.2lf %.2lf\n",++num,t,cal(t));
}
}
HDU 4717 The Moving Points(三分)的更多相关文章
- HDU 4717 The Moving Points (三分)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- hdu 4717 The Moving Points(第一个三分题)
http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小 ...
- hdu 4717 The Moving Points(三分+计算几何)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y ...
- hdu 4717 The Moving Points(三分)
http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距 ...
- hdu 4717: The Moving Points 【三分】
题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(m ...
- 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 ...
- HDU 4717 The Moving Points (三分法)
题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream& ...
- HDOJ 4717 The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- hdu4717The Moving Points(三分)
链接 需要特判一下n=1的时候 精度调太低会超时 #include <iostream> #include<cstdio> #include<cstring> #i ...
随机推荐
- posix thread 浅谈
用Posix thread进行多线程设计,就不怕跨平台了,因为很多OS都兼容Posix thread,如Linux/Windows等,甚至嵌入式系统上(如rt-thread)都支持posix thre ...
- 【linux】
virtualbox hyper-v vmware KVM LXC Utils Docker
- mac os快捷键
选中一个词,使用control+command+d,可以启用词典 option+command+d,隐藏/显示 doc command + k terminal 清除历史记录 control + up ...
- 2432: [Noi2011]兔农 - BZOJ
Description 农夫栋栋近年收入不景气,正在他发愁如何能多赚点钱时,他听到隔壁的小朋友在讨论兔子繁殖的问题. 问题是这样的:第一个月初有一对刚出生的小兔子,经过两个月长大后,这对兔子从第三个月 ...
- c++ 虚继承
虚继承(个人感觉用到的地方不多,项目中没有用到这个的) 最典型的例子就是iostream的继承方式 class istream : virtual public ios{...};//此处就是虚继承, ...
- iOS开发之数据存取3-CoreData自定义数据类型
当系统提供的类型不能达到我们的使用要求时,比如我想在CoreData中存储UIColor,该怎么办呢? 这时候就要用到CoreData中非常强大的一个存储类型了:Transformable 下面将通过 ...
- QC缺陷管理操作-细说(转)
一.缺陷常用字段说明 二.缺陷管理流程图 三.开发人员修改缺陷填写规范 四.项目经理决定延期修改缺陷 一.缺陷常用字段说明 1.摘要 对缺陷的简单描述.摘要包括该缺陷所属的模块名称-子模块名称,以及简 ...
- mysql_fetch_row,mysql_fetch_array,mysql_fetch_object,mysql_fetch_assoc区别
1.mysql_fetch_row 只能以索引下标取值,从0开始. 2.mysql_fetch_array 能以索引下标取值,也可以用字段名称取值. 3.mysql_fetch_object 对象方 ...
- 【面试题032】从1到n整数中1出现的次数
[面试题032]从1到n整数中1出现的次数 题目: 输入一个整数n,求从1到n这n个整数的十进制表示中1出现的次数. 例如输入12,从1到12这些整数中包含1的数字有1,10,11和1 ...
- SPOJ 3643 /BNUOJ 21860 Traffic Network
题意:现在已有m条单向路,问在给你的k条双向路中选择一条,使得s到t的距离最短 思路:设双向路两端点为a,b;长度为c. s到t的有三种情况: 1:原本s到t的路径 2:从s到a,a到b,b再到t的路 ...