题意:给定N个点,每个点有初始位置和初始速度。

问:在哪个时刻 使得所有的点的最大距离值最小。

分析:一开始枚举两两之间的最大值,然后在最大值中求一个最小值。。。(WA:题意严重理解不清。。)

由两点之间的距离公式(与T一个系数有关)可知,这个公式是典型的抛物线,因此可以进行三分查找答案,正解!

 /*
wa
*/
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const double inf = 9999999999.0;
const double inf2 = 1.0*(1e8);
const double pi=acos(-1.0);
const int dx[]={,-,,};
const int dy[]={,,,-};
const double eps = 1e-;
const int maxm = ;
const int maxn = ; struct NODE{
double t,d;
}mat[ maxn ][ maxn ];
struct Point{
double x,y;
double vx,vy;
}pnt[ maxn ]; double solve( double t,int n ){
double dis = ;
for( int i=;i<n;i++ ){
for( int j=i+;j<n;j++ ){
dis = max( dis, (pnt[i].x-pnt[j].x+pnt[i].vx*t-pnt[j].vx*t)*(pnt[i].x-pnt[j].x+pnt[i].vx*t-pnt[j].vx*t)+(pnt[i].y-pnt[j].y+pnt[i].vy*t-pnt[j].vy*t)*(pnt[i].y-pnt[j].y+pnt[i].vy*t-pnt[j].vy*t) );
}
}
return sqrt(dis);
} int main(){
int T;
int ca = ;
scanf("%d",&T);
while( T-- ){
int n;
scanf("%d",&n);
for( int i=;i<n;i++ ){
scanf("%lf%lf%lf%lf",&pnt[ i ].x,&pnt[ i ].y,&pnt[ i ].vx,&pnt[ i ].vy);
}
double L = ;
double R = inf2;
double ans_d = inf;
double ans_t = inf;
while( L+eps<R ){
double mid1 = ( L+R )/2.0;
double mid2 = ( mid1+R )/2.0;
double d1 = solve( mid1,n );
double d2 = solve( mid2,n );
if( d1<=d2 ) {
if( d1<ans_d ){
ans_t = mid1 ;
ans_d = d1;
}
else if( d1==ans_d )
ans_t = min( ans_t,mid1 );
R = mid2;
}
else {
if( d2<ans_d ){
ans_t = mid2 ;
ans_d = d2;
}
else if( d2==ans_d )
ans_t = min( ans_t,mid2 );
L = mid1;
}
//printf("L = %lf,R = %lf\n",L,R);
}
printf("Case #%d: %.2lf %.2lf\n",ca++,ans_t,ans_d);
}
return ;
}

最新文章

  1. $event 获取对象
  2. 搭建centos测试环境:window安装xshell,WinSCP 。 centos安装jdk tomcat
  3. 【笔记】css hover 伪类控制其他元素
  4. vi/vim使用进阶: vimrc初步
  5. 脱离 Spring 实现复杂嵌套事务,之一(必要的概念)
  6. 《C++primer》v5 第3章 字符串、向量和数组 读书笔记 习题答案
  7. bigworld源码分析(2)—— loginApp分析
  8. A*寻路初探 GameDev.net
  9. sublime text多文件夹查找关键字
  10. hdu 3157 Crazy Circuits 网络流
  11. Windows下安装BeautifulSoup
  12. 改变input中的placeholder样式
  13. hdu3488 Tour 拆点+二分图最佳匹配
  14. 修改unity变量名但不丢失序列化值
  15. 一步一步学习IdentityServer4 (3)自定登录界面并实现业务登录操作
  16. python学习之老男孩python全栈第九期_day019作业
  17. Jackson 练习(一)
  18. CALayer1-简介
  19. 杂项:HTML5-3/3-技术要点
  20. vs code开发.net core项目入门

热门文章

  1. 什么是C++标准库?
  2. 第三十九篇、NavBar动态隐藏、设置透明、毛玻璃效果
  3. MacBook Pro 的照相机在哪?
  4. Android开发之如何保证Service不被杀掉(前台服务)
  5. 洛谷 P1890 gcd区间
  6. 关键字 static
  7. 使用ckplayer搭建rtmp视频直播应用
  8. JS 正则 获取URL参数
  9. MySql 服务端与客户端下载地址
  10. iphone开发第二个程序