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.

InputThe 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 X i, Y i, VX i and VY i (-10 6 <= X i, Y i <= 10 6, -10 2 <= VX i , VY i <= 10 2), (X i, Y i) is the position of the i thpoint, and (VX i , VY i) is its speed with direction. That is to say, after 1 second, this point will move to (X i + VX i , Y i + VY i).OutputFor 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 这题也是三分的入门题(水题)
给你N个坐标,和每秒在特定方向的移动速度。
求出最大距离的最小值。(是不是和我上一篇写的,题目非常的相似)
其实两点之间的距离与时间t的关系刚好是一个二次函数。
其实又是构造一个由最大值组成的二次函数求出这个新的二次函数的最小值
 #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
struct node
{
double x,y,vx,vy;
}a[];
double f(node a,node b ,double t)
{
return sqrt((a.x+a.vx*t-b.x-b.vx*t)*(a.x+a.vx*t-b.x-b.vx*t)+(a.y+a.vy*t-b.y-b.vy*t)*(a.y+a.vy*t-b.y-b.vy*t));
}
double check(double x)
{
double maxn=;
for (int i= ;i<n ;i++){
for (int j=i+ ;j<n ;j++){
maxn=max(maxn,f(a[i],a[j],x));
}
}
return maxn;
}
int main() {
int t,cas=;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for (int i= ;i<n ;i++){
scanf("%lf%lf%lf%lf",&a[i].x,&a[i].y,&a[i].vx,&a[i].vy);
}
double l=,r=;
while(r-l>1e-){
double lmid=l+(r-l)/;
double rmid=r-(r-l)/;
if (check(lmid)>check(rmid)) l=lmid;
else r=rmid;
}
printf("Case #%d: %.2lf %.2lf\n",cas++,l,check(l));
}
return ;
}

The Moving Points HDU - 4717的更多相关文章

  1. The Moving Points - HDU - 4717 (模拟退火)

    题意 二维空间中有\(n\)个运动的点,每个点有一个初始坐标和速度向量.求出一个时间\(T\),使得此时任意两点之间的最大距离最小.输出\(T\)和最大距离. 题解 模拟退火. 这个题告诉了我,初始步 ...

  2. HDU 4717 The Moving Points (三分)

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

  3. HDOJ 4717 The Moving Points

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

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

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

  5. The Moving Points hdu4717

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

  6. HDUOJ---The Moving Points

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

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

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

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

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

  9. HDU 4717 The Moving Points(三分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...

随机推荐

  1. 洛谷 [P1182] 数列分段

    这是一道典型的二分答案问题(最大值最小,最小值最大)关键是对于细节的处理. 二分的框架: //l=max{num[i]},r=sum{num[i]} while(l<=r){ int m=(l+ ...

  2. BZOJ 3168: [Heoi2013]钙铁锌硒维生素 [线性基 Hungary 矩阵求逆]

    3168: [Heoi2013]钙铁锌硒维生素 题意:给一个线性无关组A,再给一个B,要为A中每个向量在B中选一个可以代替的向量,替换后仍然线性无关.判断可行和求字典序最小的解 PoPoQQQ orz ...

  3. spring security 4 filter 顺序及作用

    Spring Security 有两个作用:认证和授权 一.Srping security 4 filter 别名及顺序 spring security 4 标准filter别名和顺序,因为经常要用就 ...

  4. javascript 回到顶部 动画效果

    上代码: <!DOCTYPE html> <html> <head> <meta content="测试demo" name=" ...

  5. TJ4运行环境

    http://springwq2011.blog.51cto.com/4332889/966028 http://blog.csdn.net/u013573789/article/details/45 ...

  6. Oracle,Sql,procedure 感觉自己写的很棒的一个存储过程

    感觉自己写的很棒的一个Oracle存储过程,(其实想说很叼^,^). 集成了一堆操作数据的功能(至少几十), 包括存储过程执行异常信息输出帮助诊断. 亮点很多, 比如`over(partition b ...

  7. php详细学习1

    PHP中的引用 $a="now magic"; $b=&$a; $b="abc"; echo $b.$a; 结果:abcabc $a="now ...

  8. C++ 值类型和引用类型传递示例

    // win32test.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" void swap_point(int * &a , in ...

  9. chromedriver与chrome版本映射表(最新)

    selenium想在chrome进行跑,前提需要下载chromedriver,以下整理了chromedriver与chrome的对应关系表 chromedriver(下载地址):http://chro ...

  10. Eclipse中如何忽略报错的js文件

    https://jingyan.baidu.com/article/4f7d5712d3701a1a20192786.html