HDU 4717 The Moving Points (三分法)
题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少。
思路:三分。两点距离是下凹函数,它们的max也是下凹函数。可以三分。
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<vector>
#define LL long long
#define MAXN 100005
using namespace std;
struct Point
{
double x,y,vx,vy;
Point(double a,double b,double c,double d):x(a),y(b),vx(c),vy(d) {}
};
vector<Point> vec;
double calc(double time)
{
;
; i<vec.size(); ++i)
; j<vec.size(); ++j)
{
double nx=vec[i].x+vec[i].vx*time,ny=vec[i].y+vec[i].vy*time;
double mx=vec[j].x+vec[j].vx*time,my=vec[j].y+vec[j].vy*time;
maxn=max(maxn,(sqrt((nx-mx)*(nx-mx)+(ny-my)*(ny-my))));
}
return maxn;
}
int main()
{
;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
vec.clear();
;i<n;++i)
{
double a,b,c,d;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
vec.push_back(Point(a,b,c,d));
}
,R=1e8;
; i<; ++i)
{
;
;
if(calc(m1)<calc(m2)) R=m2;
else L=m1;
}
printf("Case #%d: %.2lf %.2lf\n",++kase,L,calc(L));
}
;
}
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(三分法)(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(三分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...
- 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 ...
- HDOJ 4717 The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- hdu4717 The Moving Points 三分法
题意:坐标系上有n个点,每个点的坐标和移动方向速度告诉你,速度方向都是固定的.然后要求一个时刻,使得这个时刻,这些点中最远的距离最小. 做法:三分法,比赛的时候想不到.考虑两个点,如果它们走出来的路径 ...
随机推荐
- java中对插入排序的理解以及实例
一.基本思想 通过构建有序序列,对于未排序数据,在已排序序列中从后向前扫描,找到相应的位置并插入. 插入排序非常类似于整扑克牌. 在开始摸牌时,左手是空的,牌面朝下放在桌上.接着,一次从桌上摸起一张牌 ...
- 对于JQuery的一些见解
jQuery是什么?(了解) www.github.com jQuery 其实就是一堆的js函数,是普通的js,只不过应用广泛,形成了行业标准. 参考书:锋利的jQuery 学习参考:http:// ...
- extjs 一些杂碎的技术问题
1怎样将grid 的checkedbox 勾选状态都清除 inv.getSelectionModel().clearSelections(); inv.getView().refresh(); 2怎样 ...
- 浙江理工2015.12校赛-A
孙壕请一盘青岛大虾呗 Time Limit: 5 Sec Memory Limit: 128 MB Submit: 577 Solved: 244 Description 话说那一年zstu与gdut ...
- [四校联考P3] 区间颜色众数 (主席树)
主席树 Description 给定一个长度为 N 颜色序列A,有M个询问:每次询问一个区间里是否有一种颜色的数量超过了区间的一半,并指出是哪种颜色. Input 输入文件第一行有两个整数:N和C 输 ...
- CentOS7 运行级别
linux运行的级别7个级别运行级别的查看使用 runlevelrunlevelN 3 //运行在3级别,可以理解成命令行级别级别之间的切换需要使用init x 0 //关机3 //多用户的命令行级别 ...
- gdb调试正执行的程序
参考,转载:http://biancheng.dnbcw.info/linux/391846.html
- 浅谈AJAX的基本原理和原生AJAX的基础用法
一.什么是AJAX? AJAX,即"Asynchronous Javascript And XML",翻译为异步的JavaScript和XML,是一种创建交互式网页应用的网页开发技 ...
- [转]我为什么要学习python
我为什么要学习python 引言:学习python近两年,谈谈我对于python的一点小理解,也从一些方面谈谈自己微薄的想法,也就是我为什么学习python 这里我不讨论python的一些有用的库 ...
- Java 前后端分离研究
https://github.com/ulyn/eos https://github.com/lenbo-ma/jfinal-api-scaffold/