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. 阿里巴巴分布式服务框架 Dubbo

    1.Dubbo是阿里巴巴内部的SOA服务化治理方案的核心框架,每天为2000+ 个服务提供3,000,000,000+ 次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点.Dubbo自2011年开源 ...

  2. Composer使用体验

    什么是Composer 简单来说,Composer是PHP的包依赖管理器.但是Composer并不是类似于Yum.Apt的包管理器.Composer可以用于包或者第三方库的安装,但是可以选择在Proj ...

  3. HBase目录

    1. HBase介绍及简易安装(转) 2. java操作Hbase实例 3. HBase入门基础教程之单机模式与伪分布式模式安装(转) 4. HBase教程 5. 用Java操纵HBase数据库(新建 ...

  4. Informatica 常用组件Filter之一 概述

    转换类型:已连接.主动 过滤器转换允许您过滤映射中的行.通过过滤器转换从源转换传递所有的行,然后为转换输入过滤条件.所有过滤器转换中的端口均为输入/输出端口,只有符合条件的行才能通过过滤器转换. 在某 ...

  5. BS系统经验总结

    本文章是对刚做完BS系统的总结.主要记录开发过程中遇到的问题,及问题是如何解决的. 1,界面显示 一个系统界面首先要和谐,比如不同页面文本框长度高度要统一,按钮样式要一致,表格显示一样居中都居中靠左都 ...

  6. Facade 门面模式 封装 MD

    门面模式 简介 作用:封装系统功能,简化系统调用 门面模式要求一个系统的外部与其内部的通信必须通过一个统一的门面(Facade)对象进行.门面模式提供一个高层次的接口,使得系统更易于使用. 门面模式的 ...

  7. 查看sedna创建的数据库和集合,文档之类

    在sedna的安装文件夹下.看一下cfg文件夹: <pre name="code" class="plain">[xuzhina@localhost ...

  8. Nuget出现错误怎么办?

        Go to the packages folder in the Windows Explorer and delete it. Open Visual Studio and Go to To ...

  9. [CSS3]Clearfix

    <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="index ...

  10. [Node.js]26. Level 5 : Route rendering

    Instead of just writing out the quote to the response, instead render the quote.ejs template, passin ...