题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717

题意:给出n个点的坐标和运动速度(包括方向)。求一个时刻t使得该时刻时任意两点距离最大值最小。

思路:每两个点之间的距离随时间的变化是一个开口向上的抛物线。把所有的抛物线画出来。然后每个时刻取最大值。发现这个最大值是单峰函数。

struct point
{
    double x,y;

    void get()
    {
        RD(x,y);
    }

    point(){}
    point(double _x,double _y)
    {
        x=_x;
        y=_y;
    }

    point operator+(point a)
    {
        return point(x+a.x,y+a.y);
    }

    point operator-(point a)
    {
        return point(x-a.x,y-a.y);
    }

    point operator*(double a)
    {
        return point(x*a,y*a);
    }

    double len()
    {
        return sqrt(x*x+y*y);
    }
};

point s[N],d[N];
int n;

double cal(double t)
{
    point p[N];
    int i;
    FOR1(i,n) p[i]=s[i]+d[i]*t;
    double ans=0;
    int j;
    FOR1(i,n) FOR(j,i+1,n) upMax(ans,(p[i]-p[j]).len());
    return ans;
}

double cal()
{
    double L=0,R=1e8,M1,M2;
    while(R-L>EPS)
    {
        M1=(L+R)/2;
        M2=(M1+R)/2;
        if(cal(M1)<cal(M2)) R=M2;
        else L=M1;
    }
    return L;
}

int main()
{
    int num=0;
    rush()
    {
        RD(n);
        int i;
        FOR1(i,n) s[i].get(),d[i].get();
        if(n==1)
        {
            printf("Case #%d: 0.00 0.00\n",++num);
            continue;
        }
        double t=cal();
        printf("Case #%d: %.2lf %.2lf\n",++num,t,cal(t));
    }
}

  

HDU 4717 The Moving Points(三分)的更多相关文章

  1. HDU 4717 The Moving Points (三分)

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

  2. hdu 4717 The Moving Points(第一个三分题)

    http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小 ...

  3. hdu 4717 The Moving Points(三分+计算几何)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y ...

  4. hdu 4717 The Moving Points(三分)

    http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距 ...

  5. hdu 4717: The Moving Points 【三分】

    题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(m ...

  6. 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 ...

  7. HDU 4717 The Moving Points (三分法)

    题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream& ...

  8. HDOJ 4717 The Moving Points

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

  9. hdu4717The Moving Points(三分)

    链接 需要特判一下n=1的时候 精度调太低会超时 #include <iostream> #include<cstdio> #include<cstring> #i ...

随机推荐

  1. Sales_item

    #ifndef SALESITEM_H #define SALESITEM_H // Definition of Sales_item class and related functions goes ...

  2. 使用JAXP进行sax解析

    package cn.liuning.sax; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactor ...

  3. input框中value与placeholder的区别

    value:是input中预先放置的文字,当鼠标点击之后依然存在,是值的一部分. placeholder:是input中输入位置的默认显示的文字,鼠标点击后仍旧显示,但不属于值,类似于背景.

  4. bitmap缩放时抗锯齿

    bitmap在进行放大缩小的时候经常会出现边缘锯齿的情况,通常的解决办法是在Paint中加入抗锯齿, paint.setAntiAlias(true); 但是有时候发现这并没有起到抗锯齿的作用,这是可 ...

  5. Problem 1016 咒文卷轴 优先队列+前缀和+rmq

    题目链接: 题目 Problem 1016 咒文卷轴 Time Limit: 3000 mSec Memory Limit : 131072 KB 问题描述 小Y 是一个魔法师,有一天他获得了一卷神秘 ...

  6. Hadoop集群中pig工具的安装过程记录

    在Hadoop环境中安装了pig工具,安装过程中碰到了一些问题,在此做一下记录:   主要安装流程参考:http://www.cnblogs.com/yanghuahui/p/3768270.html ...

  7. NYOJ-32 组合数 AC 分类: NYOJ 2014-01-02 22:21 112人阅读 评论(0) 收藏

    #include<stdio.h> int num[100]; int pnum(int n,int v); int mv=0; int main(){ int n,v; scanf(&q ...

  8. 【log4net】配置文件

    相关资料: http://www.cnblogs.com/dragon/archive/2005/03/24/124254.html 注意: //如果为了使得应用程序的配置文件(web/app.con ...

  9. POJ 3228 Gold Transportation(带权并查集,好题)

    参考链接:http://www.cnblogs.com/jiaohuang/archive/2010/11/13/1876418.html 题意:地图上某些点有金子,有些点有房子,还有一些带权路径,问 ...

  10. HDU 1882 Strange Billboard(位运算)

    题目链接 题意 : 给你一个矩阵,有黑有白,翻转一个块可以让上下左右都翻转过来,问最少翻转多少次能让矩阵变为全白. 思路 : 我们从第一行开始枚举要翻转的状态,最多可以枚举到2的16次方,因为你只要第 ...