题意:坐标系上有n个点,每个点的坐标和移动方向速度告诉你,速度方向都是固定的。然后要求一个时刻,使得这个时刻,这些点中最远的距离最小。

做法:三分法,比赛的时候想不到。考虑两个点,如果它们走出来的路径能在一定时间后相交的话,那么它们之间的距离肯定是先减小后增大,这样其实可以写成一个二次函数(开口朝下),然后考虑所有的点对之间的最远点,就是对所有的二次函数取一个最大值,嗯,好像还是个二次函数,呃,乱想的,想不下去了。

比赛时候想到可能是单调的或者单峰的,现在还是有点想不通,求解答。

#define maxn 403

const double eps = 1e-;

double x[maxn],y[maxn];
double xi[maxn],yi[maxn];
double tx[maxn],ty[maxn];
double _max ;
double tmp;
int n ;
double dist(double x ,double y ,double xx , double yy )
{
return sqrt((x-xx)*(x-xx)+(y-yy)*(y-yy));
}
double calc(double t)
{
for(int i = ; i <= n ; i ++ )
{
tx[i] = x[i] + xi[i] * t ;
ty[i] = y[i] + yi[i] * t ;
}
_max = ;
for(int i = ; i <= n ; i ++ )
{
for(int j= i + ; j <= n ; j ++ )
{
_max = max(_max , dist(tx[i],ty[i],tx[j],ty[j]));
}
}
return _max;
}
void Solve()
{
double Left, Right;
double mid, midmid;
double mid_area, midmid_area;
Left = 0.0;
Right = 21000000.0;
while (Left + eps < Right)
{
mid = (Left + Right) / ;
midmid = (mid + Right) / ;
mid_area = calc(mid);
midmid_area = calc(midmid);
// 假设求解最大极值.
if (mid_area <= midmid_area) Right = midmid;
else Left = mid;
}
printf("%.2lf %.2lf\n",Left,midmid_area);
} int main()
{
int cas;
int cast = ;
scanf("%d",&cas);
while(cas -- )
{
scanf("%d",&n);
for(int i = ; i <= n ; i ++ )
{
scanf("%lf%lf%lf%lf",&x[i],&y[i],&xi[i],&yi[i]);
}
printf("Case #%d: ", ++ cast);
Solve();
}
return ;
}

hdu4717 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. ACM学习历程—HDU4717 The Moving Points(模拟退火 || 三分法)

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

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

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

  4. hdu4717 The Moving Points(二分做法)

    这道题看了大家都是用三分做的,其实这道题也是可以用二分来做的,就是利用一下他们的单调性. 对于N个点,总共要考虑N(N+1)/2个距离,距离可以用二次函数表示,而且开口都是向上的. 下面具体说一下二分 ...

  5. The Moving Points hdu4717

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

  6. HDOJ 4717 The Moving Points

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

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

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

  8. HDU 4717 The Moving Points (三分)

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

  9. HDUOJ---The Moving Points

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

随机推荐

  1. RedGate 工具SQLMultiScript1.1

    原文:RedGate 工具SQLMultiScript1.1 RedGate 工具SQLMultiScript1.1 SQLMultiScript是一个脚本分发工具,当你写好了一个SQL脚本之后,你需 ...

  2. Red Gate系列之二 SQL Source Control 3.0.13.4214 Edition 数据库版本控制器 完全破解+使用教程

    原文:Red Gate系列之二 SQL Source Control 3.0.13.4214 Edition 数据库版本控制器 完全破解+使用教程 Red Gate系列之二 SQL Source Co ...

  3. 修改系统启动项 grub2配置的方法 ubuntu[转]

    在 早期的Ubuntu中,使用Grub作为系统的启动引导程序,想修改系统启动项非常简单,只要用gedit打开系统菜单设定文件( sudo gedit /boot/grub/menu.lst ),修改该 ...

  4. 【程序猿助手】Emacs,最强的编辑器,之间的不

     wx_fmt=png" alt="" style="max-width:100%; height:auto!important"> 内容简单 ...

  5. hdu 1429 胜利大逃亡(延续)(BFS+比特压缩)

    #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm& ...

  6. 在Windows基础上(硬盘)安装Linux操作系统(CentOS/RedHat)

    注:该方法安装CentOS ,RedHat均没有问题,其它Linux操作系统,没有尝试过. 0.创建一个fat32的盘.我分了8G给这个盘,盘符为F.F盘以后的内存所有删除,作为未分配的内存.这个留用 ...

  7. unity3d脚本

    一 创建和使用脚本 1 概述 GameObject的行为都是被附加到其上面的组件控制,脚本本质上也是一个组件. 在unity中创建一个脚本.默认内容例如以下: using UnityEngine; u ...

  8. poj2386 Lake Counting(简单DFS)

    转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj ...

  9. 【软件使用技巧】PL/SQL Developer实现双击table询

    二手plsql都知道,在表名默认双击[开展/关闭]. 习惯了MySql Workbench要么Sqlserver Management Studio无法适应其他管理工具. 直接在溶液: Tools - ...

  10. vs2015基于VisualStudioOnline协同工作流程

    项目负责人登陆自己的vsonline新建项目就不多说了. 直接从邀请队友开始 项目负责人操作 被邀请的邮箱务必是可以登录visualstudio的邮箱 发送邀请后,被邀请人登陆自己的邮箱,查看邀请人发 ...