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. 《编写高质量代码:改善Python程序的91个建议》读后感

    编写高质量代码:改善Python程序的91个建议  http://book.douban.com/subject/25910544/ 1.(建议16)is 用于判断两个对象的id是否相等,==才是判断 ...

  2. linux awk命令学习

    . awk的运行过程 ) awk_script的组成: ① awk_script可以由一条或多条awk_cmd组成,两条awk_cmd之间一般以NEWLINE分隔 ② awk_cmd由两部分组成: a ...

  3. 从clone()谈protected

    看到Object的clone()是protected的,然后看到<java2认证考试指南>上描述:一个对象只能请求其他对象的克隆,后者的类与被克隆对象属于同一类,或是被克隆对象的子类. e ...

  4. Windows下虚拟Linux

    andlinux cygwin virtualbox VMware XenServer

  5. Access forbidden! XAMPP虚拟主机的问题

    XAMPP Control Panel v3.2.1添加虚拟主机出现 Access forbidden! You don't have permission to access the request ...

  6. POJ2402+模拟

    题意:找出第index 个回文数. 这题是有规律的,即list[]数组. 其次,对于某个 index 可以先精确到 位数 pos,然后在进行分析. 1a #include<stdio.h> ...

  7. Power Designer 使用技巧总结

    1.设置主键自增 在表的属性界面---选择column---双击主键: 2. 为脚本添加注释: 在表的属性界面---选择column分别进行下列设置:

  8. Node.js tools for visual studio 在vs中使用Node.js

    简单介绍 PTVS开发团队又开发出一款可以在VS里编写Node.js应用程序的插件——NTVS(Node.js Tools for Visual Studio),开发者可以在VS里轻松开发Node.j ...

  9. 【Linux安全】文件或目录权限设置

    实例演示: 要求:新建文件夹,名称为secure,要求改文件夹只能被创建者deadmin以及与deadmin同组用户进行读.写.执行的权限, 其他用户均只有读的权限. 查看 一下secure原本的权限 ...

  10. Shell编程学习---第五篇:Shell的输入和输出

    在shell脚本中,可以用几种不同的方式读入数据:可以使用标准输入—缺省为键盘,或 者指定一个文件作为输入.对于输出也是一样:如果不指定某个文件作为输出,标准输出总 是和终端屏幕相关联.如果所使用命令 ...