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 ...
随机推荐
- 序列化form表单内容为json对象
SourceCode: ; (function ($) { $.fn.extend({ serializeJson: function () { var json = {}; $(this.seria ...
- Log4j详细使用教程
日志是应用软件中不可缺少的部分,Apache的开源项目log4j是一个功能强大的日志组件,提供方便的日志记录.在apache网站:jakarta.apache.org/log4j 可以免费下载到Log ...
- iOS-音频格式转换-b
iOS处理音频过程中有时候需要不同格式的音频进行转换,最近需要将m4a格式的音频转换成wav,在网上搜索之后代码整理如下: - (void)convetM4aToWav:(NSURL *)origin ...
- html5游戏引擎-Pharse.js学习笔记(一)
1.前言 前几天随着flappy bird这样的小游戏的火爆,使我这种也曾了解过html5技术的js业余爱好者也开始关注游戏开发.研究过两个个比较成熟的html5游戏引擎,感觉用引擎还是要方便一些.所 ...
- matlab和本机MySQL链接
1.安装好 ***matlab*** 和 ***mysql***: 2.[下载](http://dev.mysql.com/downloads/connector/j/#downloads) mysq ...
- pure.css
注释中address是纠正的意思 等价于correct/*! Pure v0.5.0 Copyright 2014 Yahoo! Inc. All rights reserved. Licensed ...
- Codeforces Round #130 (Div. 2) A. Dubstep
题目链接: http://codeforces.com/problemset/problem/208/A A. Dubstep time limit per test:2 secondsmemory ...
- java.util.ConcurrentModificationException 解决办法(转)
今天在项目的中有一个需求,需要在一个Set类型的集合中删除满足条件的对象,这时想当然地想到直接调用Set的remove(Object o)方法将指定的对象删除即可,测试代码: public cla ...
- 【BZOJ】【3093】【FDU校赛2012】A Famous Game
概率论 神题不会捉啊……挖个坑先 orz 贾教 & QuarterGeek /********************************************************* ...
- [vijos 1770]大内密探
描述 在古老的皇宫中,有N个房间以及N-1条双向通道,每条通道连接着两个不同的房间,所有的房间都能互相到达.皇宫中有许多的宝物,所以需要若干个大内密探来守护.一个房间被守护当切仅当该房间内有一名大内密 ...