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 <stdio.h>
#include <math.h> int N;
struct Point
{
double x,y;
double vx,vy;
}p[],a[]; double Length(Point a,Point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double F(double mid)
{
for(int j=; j<N; j++)
{
p[j].x = a[j].x+p[j].vx*mid;
p[j].y = a[j].y+p[j].vy*mid;
}
double ans=-,temp;
for(int i=; i<N-; i++)
{
for(int j=i+; j<N; j++)
{
temp=Length(p[i],p[j]);
if(ans<temp) ans=temp;
}
}
return ans;
}
int main()
{
int T,i,k,L,cnt=;
scanf("%d",&T);
while(T--)
{
scanf("%d",&N);
for(i=; i<N; i++)
{
scanf("%lf %lf %lf %lf",&p[i].x,&p[i].y,&p[i].vx,&p[i].vy);
a[i].x=p[i].x,a[i].y=p[i].y;
a[i].vx=p[i].vx,a[i].vy=p[i].vy;
}
k=;
double l=,r=1000.0,mid1,mid2;
while(k--)
{
mid1 = l +(r-l)/;
mid2 = r-(r-l)/;
if(F(mid1)<F(mid2)) r=mid2;
else l=mid1;
}
printf("Case #%d: %.2lf %.2lf\n",++cnt,l,F(l));
} return ;
}

HUD 4717

The Moving Points的更多相关文章

  1. HDOJ 4717 The Moving Points

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

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

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

  3. The Moving Points hdu4717

    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. HDU-4717 The Moving Points(凸函数求极值)

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

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

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

  8. The Moving Points HDU - 4717

    There are N points in total. Every point moves in certain direction and certain speed. We want to kn ...

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

随机推荐

  1. Cache的Add之委托解说

    正文 想了想还是写了吧,虽然知识含量比较低..... 获取数据放到缓存中,自己用Add添加的结果老是报参数错误,我擦咧,自己还总感觉是委托的问题.              call.Invoke(& ...

  2. CentOS 6.4 安装SecurectCRT并破解

    经过验证此方法使用于Centos 系列. 相关说明: 上篇发了个Linux(Ubuntu) 下 SecureCRT 7 30天循环破解在启动的时候会多输入一次确认窗口, 后来maz-1网友留言说可以用 ...

  3. OSG-3.4.0 简要说明(Readme)

    欢迎来到OpenSceneGraph(OSG)世界. Welcome to the OpenSceneGraph (OSG). 对于项目最新信息, 以及如何编译和运行库和示例的更多细节, 可以查看OS ...

  4. sparkR原理

    p.p1 { margin: 0.0px 0.0px 10.0px 0.0px; font: 11.0px "Times New Roman"; min-height: 12.0p ...

  5. codevs 1540 银河英雄传说

    题目描述 Description 公元五八○一年,地球居民迁移至金牛座α第二行星,在那里发表银河联邦创立宣言,同年改元为宇宙历元年,并开始向银河系深处拓展. 宇宙历七九九年,银河系的两大军事集团在巴米 ...

  6. MongoDB 权限认证

    MongoDB已经使用很长一段时间了,基于MongoDB的数据存储也一直没有使用到权限访问(MongoDB默认设置为无权限访问限制),因为考虑到数据安全的原因特地花了一点时间研究了一下,网上搜出来的解 ...

  7. tar + find

    将tar 和find 结合,选定目录下指定的文件类型进行打包解压: tar命令用语对文件进行归档以及恢复归档文件,"tar xzvf"命令用于释放<恢复>". ...

  8. Tesseract 3.02中文字库训练

    Tesseract 3.02中文字库训练 下载chi_sim.traindata字库下载tesseract-ocr-setup-3.02.02.exe 下载jTessBoxEditor用于修改box文 ...

  9. 实战中总结出来的CSS常见问题及解决办法

    一.ul标签在Mozilla中默认是有padding值的,而在IE中只有margin有值. 二.同一个的class选择符可以在一个文档中重复出现,而id选择符却只能出现一次.对 一个标签同时使用cla ...

  10. MySQL函数讲解(MySQL函数大全)

    讲mysql函数之前先给大家展示一下利用mysql函数的一个例子: SELECT i.item_id, i.item_name, i.cid, i.last_update_time, u.url, u ...