The Moving Points

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 964    Accepted Submission(s): 393

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
 
 #include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define eps 0.000001
typedef struct abcd
{
double x,y,vx,vy;
} point;
point p[];
int n;
double dis(double tt,int x,int y)
{
double xx=p[x].x+tt*p[x].vx;
double yy=p[x].y+tt*p[x].vy;
double xx1=p[y].x+tt*p[y].vx;
double yy1=p[y].y+tt*p[y].vy;
return sqrt((xx-xx1)*(xx-xx1)+(yy-yy1)*(yy-yy1));
}
double funa(double tt)
{
int i,j;
double maxa=;
for(i=;i<n;i++)
{
for(j=i+;j<n;j++)
{
maxa=max(maxa,dis(tt,i,j));
}
}
//cout<<tt<<endl;
return maxa;
}
double fun()
{
double l=,r=,m1,m2;
while(r-l>eps)
{
m1=l+(r-l)/;
m2=r-(r-l)/;
if(funa(m1)<funa(m2))
{
r=m2;
}
else l=m1;
}
return l;
}
int main()
{
int t,i,j,k;
scanf("%d",&t);
for(i=; i<=t; i++)
{
scanf("%d",&n);
for(j=; j<n; j++)
{
scanf("%lf%lf%lf%lf",&p[j].x,&p[j].y,&p[j].vx,&p[j].vy);
}
double yyy=fun();
printf("Case #%d: %.2lf %.2lf\n",i,yyy,funa(yyy));
}
}

The Moving Points hdu4717的更多相关文章

  1. HDU-4717 The Moving Points(凸函数求极值)

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

  2. HDOJ 4717 The Moving Points

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

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

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

  4. HDU 4717 The Moving Points (三分)

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

  5. HDUOJ---The Moving Points

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

  6. F. Moving Points 解析(思維、離散化、BIT、前綴和)

    Codeforce 1311 F. Moving Points 解析(思維.離散化.BIT.前綴和) 今天我們來看看CF1311F 題目連結 題目 略,請直接看原題. 前言 最近寫1900的題目更容易 ...

  7. ACM学习历程—HDU4717 The Moving Points(模拟退火 || 三分法)

    Description There are N points in total. Every point moves in certain direction and certain speed. W ...

  8. hdu4717 The Moving Points(二分做法)

    这道题看了大家都是用三分做的,其实这道题也是可以用二分来做的,就是利用一下他们的单调性. 对于N个点,总共要考虑N(N+1)/2个距离,距离可以用二次函数表示,而且开口都是向上的. 下面具体说一下二分 ...

  9. hdu4717 The Moving Points 三分法

    题意:坐标系上有n个点,每个点的坐标和移动方向速度告诉你,速度方向都是固定的.然后要求一个时刻,使得这个时刻,这些点中最远的距离最小. 做法:三分法,比赛的时候想不到.考虑两个点,如果它们走出来的路径 ...

随机推荐

  1. [js高手之路]设计模式系列课程-组合模式+寄生组合继承实战新闻列表

    所谓组合模式,就是把一堆结构分解出来,组成在一起,现实中很多这样的例子,如: 1.肯德基套餐就是一种组合模式, 比如鸡腿堡套餐,一般是是由一个鸡腿堡,一包薯条,一杯可乐等组成的 2.组装的台式机同理, ...

  2. Python有哪些高大上的项目?

    ​Python作为程序员的宠儿,得到了越来越多人的关注,使用Python进行应用程序开发的越来也多.那么,Python有哪些高大上的项目?这里有十个: 1.NuPIC 它是一个以HTM学习算法为工具的 ...

  3. 关联本地文件夹到github项目

    git init git remote add origin https://自己的仓库url地址 git status git add . git commit -m '[提交内容的描述]' 先 p ...

  4. ionic3 自动创建启动背景splash以及图标icon

    在新建的项目文件夹下的 resources下就是我们放置图标以及启动背景图片的位置了. 如果现在我们想生成自己的图片的启动背景以及图片,我们需要把resources下的 icon.png 以及spla ...

  5. 汇编指令-位置无关码(BL)与绝对位置码(LDR)(2)

    位置无关码,即该段代码无论放在内存的哪个地址,都能正确运行.究其原因,是因为代码里没有使用绝对地址,都是相对地址.  位置相关码,即它的地址与代码处于的位置相关,是绝对地址 BL :带链接分支跳转指令 ...

  6. PHP(Math的调用)

    <script> //数学函数(用Math来调用)://round=四舍五入最接近的整数// var l = 1.1;// var y1 = Math.round(l);// docume ...

  7. vue中组件的四种方法总结

    希望对大家有用 全局组件的第一种写法 html: <div id = "app"> <show></show></div> js: ...

  8. html标签缺省(自带)样式大全

    html标签默认样式整理 作者:佚名  来源:互联网 时间:07-30 16:54:48 文为大家整理了html标签默认样式属性及浏览器默认样式等等,喜欢css布局的朋友们可以学下,希望对大家有所帮助 ...

  9. Spring mybatis源码篇章-NodeHandler实现类具体解析保存Dynamic sql节点信息

    前言:通过阅读源码对实现机制进行了解有利于陶冶情操,承接前文Spring mybatis源码篇章-XMLLanguageDriver解析sql包装为SqlSource SqlNode接口类 publi ...

  10. Squid代理服务器安装

    代理服务器的功能是代替网络用户去访问网络信息,并把获得的信息返回给用户,其工作步骤大致如下: ) 客户机向代理服务器发起访问互联网的请求 ) 代理服务器收到请求后检查请求是否被允许,如果允许将会进行下 ...