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. python条件判断与循环

    条件判断 1.python缩进规则: 如果if语句判断是True,就把缩进的语句执行了,否则,什么也不做,比如: age=20 if age >= 18: print('your age is' ...

  2. LVS-NAT搭建HTTP及HTTPS

    author:JevonWei 版权声明:原创作品 搭建NAT模式的HTTP环境 网络拓扑图如下 网络环境 RS1 192.168.198.138 RS2 192.168.198.120 LVS: D ...

  3. matlab-常用函数(3)

    matlab取整函数: floor() floor()函数为向下取整函数,如下: floor(0.5) ans= 0 floor(-0.5) ans= -1 ceil() ceil()函数为向上取整, ...

  4. 转载 远程用户连接mysql授权

    授权法:  在安装mysql的机器上运行:  1.d:\mysql\bin\>mysql -h localhost -u root  //这样应该可以进入MySQL服务器  2.mysql> ...

  5. B树及B+树

    详见: http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp80 B树及B+树 一.B树 1.B树的定义    B树是一种平衡的多分树 ...

  6. 短视频 SDK 功能点技术实现方式详解

    第三方短视频解决方案作为快速切入短视频行业的首选方式,选择一款功能齐全.性能优异的短视频解决方案十分重要. 今天我们来谈谈短视频 SDK 6大重要功能点及其技术实现方式. 短视频拍摄 断点续拍 指在拍 ...

  7. Bootstrap框架菜鸟入门教程

    Bootstrap菜鸟入门教程 Bootstrap简介 Bootstrap,来自 Twitter,是目前最受欢迎的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的,它简 ...

  8. 1011. A+B和C (15)

    /*1011. A+B和C (15) 时间限制150 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者HOU, Qiming给定区间[-231, 231]内的3个整数A ...

  9. OpenCppCoverage 的使用

    OpenCppCoverage 的使用 OpenCppCoverage 是一款好用方便的 C++ 代码覆盖率检测工具,可以独立在命令行运行也可以作为 Visual Studio 13/15/17 的插 ...

  10. 201521123076《java程序设计》第三周学习总结

    1. 本周学习总结 2.书面作业 Q1.代码阅读 public class Test1 { private int i = 1;//这行不能修改 private static int j = 2; p ...