HDOJ 4717 The Moving Points
The Moving Points
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 878 Accepted Submission(s): 353
For each test case, first line has a single number N (N <= 300), which is the number of points.
For next N lines, each come with four integers Xi, Yi, VXi and VYi (-106 <= Xi, Yi <= 106, -102 <= VXi , VYi <= 102), (Xi, Yi) is the position of the ith point, and (VXi , VYi) is its speed with direction. That is to say, after 1 second, this point will move to (Xi + VXi , Yi + VYi).
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const double eps=1e-;
const double INF=0x3f3f3f3f; struct point
{
double x,y;
double vx,vy;
point() {}
point(double a,double b,double c,double d):x(a),y(b),vx(c),vy(d){}
}P[]; double getP2Pdist(point a,point b,double t)
{
double x1=a.x+t*a.vx,y1=a.y+t*a.vy;
double x2=b.x+t*b.vx,y2=b.y+t*b.vy;
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
} double LMdist(int n,double t)
{
double ans=-INF;
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
ans=max(ans,getP2Pdist(P[i],P[j],t));
}
}
return ans;
} int main()
{
int t,n,cas=;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<n;i++)
{
double a,b,c,d;
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
P[i]=point(a,b,c,d);
}
double low=,high=,midlow,midhigh;
int cnt=;
while(cnt<=)
{
cnt++;
midlow=(low*+high)/.,midhigh=(low+high*)/.;
double distlow=LMdist(n,midlow);
double disthigh=LMdist(n,midhigh);
if(distlow>disthigh) low=midlow;
else high=midhigh;
}
double anstime=low;
double ansdist=LMdist(n,low);
printf("Case #%d: %.2lf %.2lf\n",cas++,anstime,ansdist);
}
return ;
}
* This source code was highlighted by YcdoiT. ( style: Codeblocks )
HDOJ 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个点的坐标和运动速度(包括方向).求一个时刻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(三分法)(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 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距 ...
- HDU 4717 The Moving Points (三分法)
题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream& ...
- hdu 4717: The Moving Points 【三分】
题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(m ...
- HDU 4717The Moving Points warmup2 1002题(三分)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
随机推荐
- Windows8远程桌面CentOS 6.5
概述: 在CentOS上安装vncserver和Windows8上安装VNC Viewer,从而可以在Windows8远程桌面到CentOS 6.5 1. 在CentOS上安装vncserver 1. ...
- [Android]加密技术
对称加密无论是加密还是解密都使用同一个key,而非对称加密需要两个key(public key和private key).使用public key对数据进行加密,必须使用private key对数据进 ...
- Git更新到最新版本
添加git的ppa源sudo apt-add-repository ppa:git-core/ppasudo apt-get updatesudo apt-get upgrade
- SQL Server 2012 学习笔记1
1. 新建的数据库会产生两个文件(数据文件.mdf 和日志文件.ldf) 2. 编辑表格和为表格录入数据 "Design"为设计表格,"Edit Top 200 Rows ...
- 关于Linux发行版的选择
Linux发行版很多,分为以RedHat为代表的商业发行版和以Debian为代表的免费发行版.前者典型版本有CentOS.Fedora.SUSE等,后者的典型版本有Ubuntu等 CentOS.Ubu ...
- C#--几个数据流Stream;StreamReader;StreamWriter;MemoryStream;BufferStream;
命名空间:System.IO; Stream: 各种流的基类,不能时行查找操作,Position属性不能修改.读取时不Position不会自动移动, HttpWebRequest webreq = ( ...
- Xcode如何编译Debug版和Release版
在Run和Stop按钮的右边有一个工程名 点击工程名,选择Manage Schemes 选择Edit... 左侧选择Run ProjectName.app 右侧选择Info页,在Build Confi ...
- JAVA Applet
- 用户信息 Froms验证票证
Froms票证是为了存储一些有用信息在客户端..一般都与Cookie一起使用.. , entity.LoginName, DateTime.Now, DateTime.Now.AddMonths( ...
- Java备份约9亿条数据
需求:有一张表9亿多条数据,数据加索引总数据量61GB.考虑到这张表的大部分数据都不会再被使用并且大数据量可能影响整库的性能,所以决定将表里某一个时刻之前的数据备份到一张新表中,待备份完成后将旧表中已 ...