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. CF487 E. Tourists [点双连通分量 树链剖分 割点]

    E. Tourists 题意: 无向连通图 C a w: 表示 a 城市的纪念品售价变成 w. A a b: 表示有一个游客要从 a 城市到 b 城市,你要回答在所有他的旅行路径中最低售价的最低可能值 ...

  2. Java随感

    创新项目要用java,而我只大概会C++,只能靠自学咯~~~随时将一些重要的概念做笔记在这里吧>_< 1.一个源文件中只能有一个public类,一个源文件可以有多个非public类 2.所 ...

  3. BZOJ 2142: 礼物 [Lucas定理]

    2142: 礼物 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 1294  Solved: 534[Submit][Status][Discuss] ...

  4. 【css3】旋转倒计时

    很多答题的H5界面上有旋转倒计时的效果,一个不断旋转减少的动画,类似于下图的这样. 今天研究了下,可以通过border旋转得到.一般我们可以通过border得到一个四段圆. See the Pen c ...

  5. mac下自带的Apache+PHP环境输出错误提示

    sudo vim /etc/php.ini 找到 display_errors = Off ,把Off 改为 On . 最后为 display_errors = On ; 找到 error_repor ...

  6. css为第几个倍数元素添加样式

    //3n就是3的倍数都加这个样式*/.list li:nth-child(3n){ border-bottom:1px;}

  7. 微信开发系列——微信订阅号前端开发利器:WeUI

    前言:年前的两个星期,学习了下微信公众号的开发.后端基本能够基于盛派的第三方sdk能搞定大部分事宜.剩下的就是前端了,关于手机端的浏览器的兼容性,一直是博主的一块心病,因为博主一直专注于bootstr ...

  8. 借腾讯开源 VasDolly,谈谈 Android 签名和多渠道打包的原理!

    一.前言 Hi,大家好,我是承香墨影! 当我们需要发布一款 App 到应用市场的时候,一般需要我们针对不同的市场生产不同的渠道包,它们使用的是同一套代码,只是会包含一些各自的渠道信息,用于我们做数据分 ...

  9. Duilib第一步(III)-知识进阶

    核心模块 CWindowWnd:窗口对象管理父类 创建窗口. 窗口消息过程处理. 提供窗口子类化.超类化接口. CDialogBuilder:空间布局类 解析XML界面布局文件,构建控件树 创建控件对 ...

  10. CompletableFuture CompletableFuture.supplyAsync 异常处理

    CompletableFuture 异常处理completeExceptionally可以把异常抛到主线程 /** * User: laizhenwei * Date: 2018-01-30 Time ...