题目链接

第一次写三分

三分的基本模板

int SanFen(int l,int r) //找凸点
{
while(r-l>)
{
//mid为中点,midmid为四等分点
int mid = (l+r)/;
int midmid = (mid+r)/;
if( f(mid) > f(midmid) )
r = midmid;
else
l = mid;
}
return f(l) > f(r) ? l : r;
}

这道题里面任意两点的距离都可以看作是一个凹函数,对任意t对所有凹函数取最大值构成一个新的凹函数,求新函数的最小值

#include<bits/stdc++.h>
using namespace std;
typedef long long LL; const int N=;
const double eps=1e-; int T,n;
double tim,mindis; struct point
{
double x,y;
int dx,dy;
}p[N]; double dist(point p1,point p2,double t)
{
double x2=(p1.x+t*p1.dx-p2.x-t*p2.dx)*(p1.x+t*p1.dx-p2.x-t*p2.dx);
double y2=(p1.y+t*p1.dy-p2.y-t*p2.dy)*(p1.y+t*p1.dy-p2.y-t*p2.dy);
return sqrt(x2+y2);
} double cal(double x)
{
double ret=-;
for(int i=;i<n;i++)
for(int j=i+;j<n;j++)
ret=max(ret,dist(p[i],p[j],x));
return ret;
} void solve()
{
double l=,r=1e8;
while(r-l>eps)
{
double mid=(l+r)/;
double midmid=(mid+r)/;
double ans1=cal(mid);
double ans2=cal(midmid);
if(ans1>ans2) l=mid;
else r=midmid;
}
tim=l;
mindis=cal(tim);
} int main()
{
scanf("%d",&T);
for(int kase=;kase<=T;kase++)
{
scanf("%d",&n);
for(int i=;i<n;i++)
scanf("%lf%lf%d%d",&p[i].x,&p[i].y,&p[i].dx,&p[i].dy);
solve();
printf("Case #%d: %.2lf %.2lf\n",kase,tim,mindis);
}
}

hdu_4717: The Moving Points 【三分】的更多相关文章

  1. hdu4717The Moving Points(三分)

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

  2. HDU 4717 The Moving Points(三分)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...

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

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

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

  6. HDU-4717 The Moving Points(凸函数求极值)

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

  7. HDOJ 4717 The Moving Points

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

  8. The Moving Points hdu4717

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

  9. F. Moving Points 解析(思維、離散化、BIT、前綴和)

    Codeforce 1311 F. Moving Points 解析(思維.離散化.BIT.前綴和) 今天我們來看看CF1311F 題目連結 題目 略,請直接看原題. 前言 最近寫1900的題目更容易 ...

随机推荐

  1. python 创建mysql数据库

    昨天用shell脚本创建数据库,涉及java调用,比较折腾,改用python直接创建数据库,比较方便,好了,直接上代码,相关注释也添加了 # _*_encoding:UTF-8_*_import My ...

  2. 基于NIO的Netty网络框架

    Netty是一个高性能.异步事件驱动的NIO框架,它提供了对TCP.UDP和文件传输的支持,Netty的所有IO操作都是异步非阻塞的,通过Future-Listener机制,用户可以方便的主动获取或者 ...

  3. 在firefox的flashgot中配置各种下载器

    一.在firefox中安装flashgot下载管理器 flashgot是firefox的一个扩展,在联网的情况下,可以在firefox中的附加组件中搜索flashgot,然后安装. 二.在flashg ...

  4. js前端实现多图图片上传预览

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...

  5. js删除 object中的空值

    var data = { a: 'a', b: '' } 删除 b和''的配对, /** * Delete all null (or undefined) properties from an obj ...

  6. Go - concurrency

    并发 vs 并行 首先,我们先来搞清楚概念以及并发和并行的区别. 并发 - 利用时间片切换来实现“同时”运行的. 并行 - 利用CPU的多核来实现通过多线程来实现同时运行. Go 语言的设计理念就是通 ...

  7. Xmanager连接到RedHat Enterprise Linux 6.8

    RedHat Enterprise Linux 6 配置Xmanager ,实现图形界面连接 X是用在大多数UNIX系统中的图形支持系统.如果你在你的Linux机器上使用GNOME或者KDE的话,你就 ...

  8. CSS(3)实现水平垂直居中效果

    CSS实现水平垂直居中对齐 在CSS中实现水平居中,会比较简单.常见的,如果想实现inline元素或者inline-block元素水平居中,可以在其父级块级元素上设置text-align: cente ...

  9. ecshop的aes加密(封装)

    从一家做shopex,ecstore的公司到一家做b2b的ecshop的公司...来了就要实战,其他的不说了,先来了解什么是php的aes加密吧? aes(高级加密标准),AES的区块长度固定为128 ...

  10. loadrunner 手工参数拼接与l oadrunner的url编码

    Acction() { //演示需要的一些变量,提前声明 char *name = "yezi_zh"; "; char *work = "engin" ...