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. 有标号DAG计数 [容斥原理 子集反演 组合数学 fft]

    有标号DAG计数 题目在COGS上 [HZOI 2015]有标号的DAG计数 I [HZOI 2015] 有标号的DAG计数 II [HZOI 2015]有标号的DAG计数 III I 求n个点的DA ...

  2. selenium+requests访问微博

    import requests from selenium import webdriver from selenium.webdriver.support import expected_condi ...

  3. 如何在Python中从零开始实现随机森林

    欢迎大家前往云+社区,获取更多腾讯海量技术实践干货哦~ 决策树可能会受到高度变异的影响,使得结果对所使用的特定测试数据而言变得脆弱. 根据您的测试数据样本构建多个模型(称为套袋)可以减少这种差异,但是 ...

  4. Linux下的压力测试工具:ab、http_load、webbench、siege

    一.ab 1.1 介绍 ab是apache自带的一款功能强大的测试工具.      安装了apache一般就自带了. 1.2 下载 同apache. 1.3 安装 同apache. 1.4 安装结果 ...

  5. file_put_contents写入文字换行

    file_put_contents写入文字换行 注意要使用双引号 "\r\n"

  6. java 流输出的一些问题

    一.java流的控制首先要先准备一个文件,例如:File f = new File(d:/lol.txt); 二.可以使用如下指令创建流,用于不同的用途 1.FileInputStream,FileO ...

  7. python入门学习笔记(三)

    10.函数 求绝对值的函数 abs(x) 也可以在交互式命令行通过 help(abs) 查看abs函数的帮助信息.调用 abs 函数:>>> abs(100)100>>& ...

  8. PowerDesigner 简单应用(转载)

    PowerDesigner是一款功能非常强大的建模工具软件,足以与Rose比肩,同样是当今最著名的建模软件之一.Rose是专攻UML对象模型的建模工具,之后才向数据库建模发展,而PowerDesign ...

  9. 老男孩Python全栈开发(92天全)视频教程 自学笔记17

    day17课程内容: 装饰器回顾练习 登录功能: #登录京东,不同的页面,选择页面,然后不同的登录方式with open('作业5.1jingdong','w',encoding='utf8') as ...

  10. 压缩tar命令

    option z表示压缩,所以才有后面的.gz, c表示创建这个压缩包,v是可视,能看到其打包和压缩的过程,f表示文件 zcvf 命令格式为 先压缩后跟压缩的目录 tar zcvf /home/xia ...