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. PHPCMS 核心代码与 www 分离部署

    为了满足更多用户二次开发的兴趣与爱好,同时,为了更加安全.可以通过修改入口代码的包含方式来让主程序和www程序分开. 先看下面目录结构: (图1) 我们需要将 phpcms 目录和 index.php ...

  2. Python 基础篇:编码、变量、模块

    1. 编码 python解释器在加载 .py 文件中的代码时,会对内容进行编码(默认ASCII). 2. 变量 变量定义的规则: 变量名只能是 字母.数字或下划线的任意组合 变量名的第一个字符不能是数 ...

  3. ImportError: No module named pysqlite2 --安装pysqlite

    yum install sqlite-devel -y pip install pysqlite 每次使用yum安装额外的包之后都需要重新安装python,否则可能会有各种奇奇怪怪的问题出现 cd P ...

  4. 对WPF中MeasureOverride 和ArrangeOverride 浅理解

    以前对MeasureOverride 和ArrangeOverride十分费解,看到了这篇博文茅塞顿开~ public class CustomControl1 : Panel { /// <s ...

  5. 【Base64】JDK里面实现Base64的API

    原文出处: 成熟的毛毛虫的博客 BASE64 编码是一种常用的字符编码,在很多地方都会用到.但base64不是安全领域下的加密解密算法.能起到安全作用的效果很差,而且很容易破解,他核心作用应该是传输数 ...

  6. VisualStudio自定义代码段_方法一

    在VisualStudio里,使用代码段会提高我们的编写速度.其实,就是给一段代码加个快捷方式,使用时,快捷方式按键+2次Tab键. 举个例子: 比如输入Console.WriteLine (); 传 ...

  7. 使用JProfiler进行内存分析

    在最近的工作中,通过JProfiler解决了一个内存泄漏的问题,现将检测的步骤和一些分析记录下来,已备今后遇到相似问题时可以作为参考. 运行环境: Tomcat6,jdk6,JProfiler8 内存 ...

  8. activity的测试工程activiti-explorer使用

    1. activiti-explorer默认使用h2数据库,第一步要修改db.properties的配置,如果使用其他数据库的话,务必放入驱动包,oracle的ojdbc4不能用,会报错,要使用版本高 ...

  9. 如何让Activiti-Explorer使用sql server数据库

    从官网下载的Activiti-explorer的war文件内部默认是使用h2内存数据库的,如果想改用其他的数据库来做持久化,比如sql server,需要做如下配置. 1)修改db.propertie ...

  10. UVA 10273 Eat or Not to Eat?

    这个题目一直以为是要用图论知识来做,可是一点建图的思绪都没有,后来知道暴力便可破之.由于牛的产奶周期最大为10,1.2.3.....10的最小公倍数是MT = 2520,所以把MT作为最大的周期,然后 ...