The Moving Points

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 612    Accepted Submission(s): 250

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
 
Source
 
Recommend
zhuyuanchen520
三分思路:
单调性查找就好....对时间
代码:
 #include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define MAX 1e9
#define exp 1e-6
using namespace std;
//设置结构体
typedef struct
{
int x,y;
int px,py;
}point; //计算任意时间两点的距离
double das(point a,point b,double t )
{
return sqrt(pow(((a.x+a.px*t)-(b.x+b.px*t)),)+pow(((a.y+a.py*t)-(b.y+b.py*t)),));
}
//判断两个数最大值....
double max( double a,double b)
{
return a>b?a:b;
}
point po[];
int main()
{
int n,i,j,cnt=,t;
double ll,rr,ml,mr,ans1,ans2;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for( i= ; i<=n ; i++ )
{
scanf("%d%d%d%d",&po[i].x,&po[i].y,&po[i].px,&po[i].py);
//cin>>po[i].x>>po[i].y>>po[i].px>>po[i].py;
}
//没有其他的办法,除了遍历之外
ll=0.0,rr=MAX;
while(rr-ll>exp)
{
ans1=ans2=0.0;
//ml=(ll+rr)/2.0; //慢很多
//mr=(ml+rr)/2.0;
ml=(ll*+rr)/3.0; // r/3.0 较快
mr=(ll+rr*)/3.0; // 2*r/3.0
for( i= ; i<n ; i++ )
{
for( j=i+ ; j<=n ;j++ )
{
ans1=max(ans1,das(po[i],po[j],ml)); //对左边
ans2=max(ans2,das(po[i],po[j],mr)); //对右边
}
}
if( ans1<ans2 )
rr=mr;
else
ll=ml;
}
//得到时间ll or rr 都可以
ans1=0.0;
for(i= ; i<n ; i++ )
{
for(j=+i ; j<=n ;j++)
{
ans1=max(ans1,das(po[i],po[j],ll)); //对左边ll/rr
}
}
printf("Case #%d: %.2lf %.2lf\n",cnt++,ll,ans1);
}
return ;
}

HDUOJ---The Moving Points的更多相关文章

  1. HDOJ 4717 The Moving Points

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

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

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

  3. The Moving Points hdu4717

    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. HDU-4717 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. The Moving Points

    Problem Description There are N points in total. Every point moves in certain direction and certain ...

  8. The Moving Points HDU - 4717

    There are N points in total. Every point moves in certain direction and certain speed. We want to kn ...

  9. HDU 4717 The Moving Points(三分法)(2013 ACM/ICPC Asia Regional Online ―― Warmup2)

    Description There are N points in total. Every point moves in certain direction and certain speed. W ...

随机推荐

  1. numpy转换

    csv2npy cccsv=numpy.genfromtxt('/root/c.csv', delimiter = ',') buf2npy imga=numpy.frombuffer(buf,num ...

  2. poj 1007 Quoit Design(分治)

    Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  3. linux进程、调度、线程、进程上下文等几点理解

    1.信号来自进程或内核 2.线程共享进程的代码空间和数据空间(全局变量或静态变量),文件描述符,信号,以及malloc分配的内存,每个线程拥有独立的栈空间和程序计数器,在创建线程时,调用pthread ...

  4. 20个代码生成框架 (.NET JAVA)

    1.1 CodeSmith 一款人气很旺国外的基于模板的dotnet代码生成器 官方网站:http://www.codesmithtools.com 官方论坛:http://forum.codesmi ...

  5. 【Nodejs】理想论坛帖子下载爬虫1.04

    一直想做一个能把理想论坛指定页范围的帖子都能完整下载下来的爬虫,但未能如愿. 主要的障碍在并发数的控制和长时间任务的突然退出,比如想下载前五页的帖子,分析后可得到大约15000个主贴或子贴,如果用回调 ...

  6. rapidxml 解析修改内存的值

    1.使用rapidxml解析的时候,也就是 调用xmlDoc.parse<0>(xmlContent),特别注意,rapidxml会修改内存的值,把右尖括号>修改为'\0',因此特别 ...

  7. 极客Web前端开发资源集锦

    本周我们带来的前端推荐包含当前热门的bootstrap,html5,css3等技术内容和新闻话题,如果你还想近一步学习如何开发,还可以关注我们的极客课程库,里面涵盖了现代开发技术的‘学’与‘习’的全新 ...

  8. ZH奶酪:PHP判断图片格式的7种方法

    以图片 $imgurl = "http://www.php10086.com/wp-content/themes/inove/img/readers.gif"; 为例: 思路1. ...

  9. 分享几个.NET 下的计划任务组件

    Quartz http://www.quartz-scheduler.net/(现项目在使用,可以看我之前的文章) Hangfire http://hangfire.io/ Install-Packa ...

  10. 当Activity继承AppCompatActivity如何实现隐藏标题栏与状态栏

    @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); g ...