hdu 4717 The Moving Points(三分+计算几何)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717
说明下为啥满足三分:
设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y的变化。则f(x)函数单调性有两种:1.先单减,后单增。2.一直单增。
设y=m(x) (x>0)表示随时间x的增长,所有点的最大距离y的变化。即m(x)是所有点对构成的f(x)图像取最上面的部分。则m(x)的单调性也只有两种可能:1.先单减,后单增。2.一直单增。 这个地方的证明可以这样:假如时刻t1到时刻t2最大值取得是函数f1(x)的图像,在时刻t2到时刻t3取得是f2(x)的图像,

那么由图可以看出f2(x)的斜率大于f1(x)的斜率
可以归纳出m(x)函数的斜率是递增。那么单调性就可以知道了。
m(x)有了上面的性质,就可以有三分了。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; const double eps = 1e-;
const double PI = acos(-1.0);
const double INF = 1000000000000000.000; struct Point{
double x,y;
Point(double x=, double y=) : x(x),y(y){ } //构造函数
};
typedef Point Vector; Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);}
Vector operator * (double p,Vector A){return Vector(A.x*p,A.y*p);}
Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){
return a.x < b.x ||( a.x == b.x && a.y < b.y);
} int dcmp(double x){
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b){
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} ///向量(x,y)的极角用atan2(y,x);
inline double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; }
inline double Length(Vector A) { return sqrt(Dot(A,A)); }
inline double Angle(Vector A, Vector B) { return acos(Dot(A,B) / Length(A) / Length(B)); } Point read_point(){
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
} /*************************************分 割 线*****************************************/
const int maxn = ; Point P[maxn];
Vector V[maxn];
int N; double calMax(double t){
double ret = ;
for(int i=;i<=N;i++)
for(int j=i+;j<=N;j++){
double len = Length(P[i]+t*V[i]-(P[j]+t*V[j]));
ret = max(ret,len);
}
return ret;
} int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
int T;
cin>>T;
for(int cas=;cas<=T;cas++){
cin>>N;
for(int i=;i<=N;i++){
P[i] = read_point();
V[i] = read_point();
} double Lt=;
double Rt=1e7; double M1t,M1w;
double M2t,M2w;
while(dcmp(Rt-Lt)>){
M1t = Lt+(Rt-Lt)/;
M1w = calMax(M1t); M2t = Lt+(Rt-Lt)/*;
M2w = calMax(M2t); if(dcmp(M1w-M2w)>=){
Lt = M1t+eps;
}
else{
Rt = M2t-eps;
}
}
printf("Case #%d: %.2lf %.2lf\n",cas,Lt,calMax(Lt));
}
}
hdu 4717 The Moving Points(三分+计算几何)的更多相关文章
- HDU 4717 The Moving Points(三分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...
- 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 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距 ...
- hdu 4717 The Moving Points(第一个三分题)
http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小 ...
- 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 ...
随机推荐
- VS2010对Excel操作---DLL向
最近公司有个项目要用到Excel的操作,于是自己就对VC中关于Excel的操作进行整理了下.而这里我是直接做成DLL方便他人调用的. 创建一个MFC Dll项目. 选择MFC扩展DLL. 在“类视图” ...
- My97 DatePicker 选择时间后弹出选择的时间
项目中用到这个时间插件,注册用户时可以选中永久和选择时间,二者是互斥关系, 所以在选择时间插件时,需要绑定一个事件,所以看到了这个插件: <input id="yydate" ...
- [LeetCode OJ] Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...
- PHP程序开发人员要掌握的知识
文件目录处理函数包80%以上的函数的功能的灵活运用. 日期时间函数中的80%以上的函数的功能的灵活运用 数学函数库中的100%的内容. 网络库中的60%以上的内容,对各个函数的功能比较熟悉. 字符串处 ...
- iphone5手机端内容超出iphone6没问题且超出内容为http://.....网址
- java基础部分
1.java的基本数据类型及所占的字节 boolen 8位 1个字节 byte 8位 1个字节 char 16位 2个字节 short 16位 2个字节 int 32位 4个字 float 32位 ...
- C语言学习总结(三) 复杂类型
第五章.复杂数据类型 (数组.字符串.指针.结构体.枚举.共同体) 1.什么是数组? 概念:把具有相同类型的若干变量按有序的形式组织起来,这些按序排列的同类数据元素的集合称为数组: 按数组元素的类型不 ...
- 练习2 E题 - 求奇数的乘积
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description 给你n ...
- 流的概念(来自MSDN)
本文来源 定义 提供字节序列的一般视图.Provides a generic view of a sequence of bytes. 流涉及三个基本操作 Streams involve three ...
- matplotlib 绘图
http://blog.csdn.net/jkhere/article/details/9324823 都打一遍 5 matplotlib-绘制精美的图表 matplotlib 是python最著名的 ...