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个点,每个点的坐标和移动方向速度告诉你,速度方向都是固定的.然后要求一个时刻,使得这个时刻,这些点中最远的距离最小. 做法:三分法,比赛的时候想不到.考虑两个点,如果它们走出来的路径 ...
随机推荐
- 关于mysql中int(1)中int后面的数字
mysql在建表的时候int类型后的长度代表什么? 是该列允许存储值的最大宽度吗? 为什么我设置成int(1), 也一样能存10,100,1000呢. 当时我虽然知道int(1),这个长度1并不代表 ...
- Wormholes
Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes ...
- CMD执行BCP命令
C:\>BCP "EXEC GetU '2016-7-11' ,'-1'" queryout "C:\\C3Marketing\SummaryReport_test ...
- Bootstrapper.cs
using System.Windows; using Microsoft.Practices.Prism.Modularity; using Microsoft.Practices.Prism.Un ...
- Redundant Paths-POJ3177(并查集+双连通分量)
Redundant Paths Description In order to get from one of the F (1 <= F <= 5,000) grazing fields ...
- /var/spool/postfix/maildrop 占用inode索引及磁盘空间解决办法
1.问题表现和检查 运行df -i / 查看inode使用是否满: 2.查看/var/spool/postfix/maildrop是否有非常多的小文件,ls直接卡死等情况 解决: 删除小文件: cd ...
- noi 1768 最大子矩阵
题目链接:http://noi.openjudge.cn/ch0206/1768/ 可能是数据修改了吧,O(n6)过不了了. 主要是在求一个矩阵的和时,重复计算了很多次. 矩阵首先压缩一下.在输入的时 ...
- (转)建站知识:域名/ 空间/ IP/ 端口之间的关系
先说域名解析吧,比如说你的域名是 www.sunnymould.com,这个域名对应着一个IP地址,域名解析就是把上面的域名转换成这个IP地址的过程,这样你就可以域名访问了上面地址上的内容了. 端口映 ...
- Fiddler—PC上实现手机的抓包
PC上安装Fiddler之后,可以抓取各种浏览器的请求,通过一些设置可以获取iPhone.安卓手机.windows phone的请求.具体的工作原理我也不多说(哼,绝对不是因为我不懂XD),主要说下如 ...
- 【Spring】搭建最简单的Spring MVC项目
每次需要Spring MVC的web项目测试一些东西时,都苦于手头上没有最简单的Spring MVC的web项目,现写一个. > 版本说明 首先要引入一些包,Spring的IOC.MVC包就不用 ...