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 ...
随机推荐
- delete表1条件是另一个表中的数据,多表连接删除(转)
DELETE删除多表数据,怎样才能同时删除多个关联表的数据呢?这里做了深入的解释: 1. delete from t1 where 条件 2.delete t1 from t1 where 条件 3. ...
- linux下memcache的运用,和php结合小案例。
由于是采用脚本安装的memache,所以软件的依赖关系我就不操心了,脚本已经帮我装好了和php的关联关系,实在是很省心.后续如果有需要,我会针对windows和linux各写一个安装和配置的说明,一来 ...
- gnuplot conditional plotting: plot col A:col B if col C == x
http://stackoverflow.com/questions/6564561/gnuplot-conditional-plotting-plot-col-acol-b-if-col-c-x H ...
- Linux bash 中,如何将正常信息和错误信息输出到文件
问题描述: $ command 2>> error $ command 1>> output 是否有方法,在bash同一行,实现输出stderr到error文件,输出stdou ...
- PHP 基本语法,字符串处理,正则
<?php //注释语法 /*多行注释*/ 输出语法 Echo "hello","worle"; //可以输出多个字符串 Print ...
- css3实现小黄人
效果就像这样: 不废话,直接上代码! hrml代码: <!DOCTYPE html> <html> <head lang="zh"> <m ...
- JNI笔记
由于要做一个能够加红字体的dialog,而cocos2d中的CCMessageBox是系统内带的,我无法修改其字体颜色.事实上是可以修改的,通过观察发现CCMessageBox被调用后,在安卓平台中会 ...
- spring-boot-cli
- linux curl 命令详解,以及实例
linux curl是一个利用URL规则在命令行下工作的文件传输工具.它支持文件的上传和下载,所以是综合传输工具,但按传统,习惯称url为下载工具. 一,curl命令参数,有好多我没有用过,也不知道翻 ...
- Http请求之--C#的HttpWebRequest实现POST方式请求
1.添加头信息和请求方法.有两种方式添加 req = (HttpWebRequest)WebRequest.Create("http://zhidao.baidu.c ...