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

Problem Description
There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we require you to calculate that minimum distance. We guarantee that no two points will move in exactly same speed and direction.
 
Input
The rst line has a number T (T <= 10) , indicating the number of test cases.
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).
 
Output
For test case X, output "Case #X: " first, then output two numbers, rounded to 0.01, as the answer of time and distance.
 
Sample Input
2
2
0 0 1 0
2 0 -1 0
2
0 0 1 0
2 1 -1 0
 
Sample Output
Case #1: 1.00 0.00
Case #2: 1.00 1.00
 
Source
 
Recommend
zhuyuanchen520
 
 #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的更多相关文章

  1. HDU 4717 The Moving Points (三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  2. HDU 4717 The Moving Points(三分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...

  3. hdu 4717 The Moving Points(第一个三分题)

    http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小 ...

  4. hdu 4717 The Moving Points(三分+计算几何)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y ...

  5. 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 ...

  6. hdu 4717 The Moving Points(三分)

    http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距 ...

  7. HDU 4717 The Moving Points (三分法)

    题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream& ...

  8. hdu 4717: The Moving Points 【三分】

    题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(m ...

  9. HDU 4717The Moving Points warmup2 1002题(三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

随机推荐

  1. @EmbeddedId和@idClass的区别

    @idClass 使复合主键类成为非嵌入类,使用 @IdClass 批注为实体指定一个复合主键类(通常由两个或更多基元类型或 JDK 对象类型组成).从原有数据库映射时(此时数据库键由多列组成),通常 ...

  2. Linux使用网盘客户端

    1. 百度网盘 - bypy https://github.com/houtianze/bypy 这是一个基于Python的命令行客户端. 安装参考上面链接的说明,或者这篇文章(推荐,有告诉你如何安装 ...

  3. AngularJs angular.element

    angular.element 将DOM元素或者HTML字符串一包装成一个jQuery元素. 格式:angular.element(element); element:包装成jquery对象的html ...

  4. python模块xlrd安装-处理excel文件必须

    我安装了很久,网上查了很多资料,但都不太适合,综合 了一下,再写一写,希望有用... 官网下载xlrd:官网xlrd下载地址, 真的很难下,我用讯雷,有时候断断续续 下面是我的百度网盘地址,分享出来, ...

  5. python click module for command line interface

    Click Module(一)                                                  ----xiaojikuaipao The following mat ...

  6. IIS Express 外部访问

    http://blog.csdn.net/zhangjk1993/article/details/36671105

  7. mvc-1

  8. codeforces 719C (复杂模拟-四舍五入-贪心)

    题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...

  9. 虚拟机NUMA和内存KSM

    KSM技术可以合并相同的内存页,即使是不同的NUMA节点,如果需要关闭跨NUMA节点的内存合并,设置/sys/kernel/mm/ksm/merge_across_nodes参数为0.或者可以关闭特定 ...

  10. HighCharts学习笔记(二)HighCharts结构及详细配置

    HighCharts结构及详细配置: 一.HighCharts整体结构: 通过查看API文档我们知道HighCharts结构如下:(API文档在文章后面提供下载) var chart = new Hi ...