题目链接

第一次写三分

三分的基本模板

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. HDU 4717 The Moving Points(三分)

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

  2. HDU 4717 The Moving Points (三分)

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

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

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

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

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

  5. hdu 4717 The Moving Points(三分)

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

  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. 消息队列之 ActiveMQ

    简介 ActiveMQ 特点 ActiveMQ 是由 Apache 出品的一款开源消息中间件,旨在为应用程序提供高效.可扩展.稳定.安全的企业级消息通信. 它的设计目标是提供标准的.面向消息的.多语言 ...

  2. DelayQueue 源码分析

    DelayQueue DelayQueue 是基于 PriorityQueue 实现的线程安全的无界优先级阻塞队列, 队列的头部元素必须在超时后才能移除,元素必须实现 Delayed 接口. 创建实例 ...

  3. Struts2 Convention Plugin ( struts2 零配置 )

    Struts2 Convention Plugin ( struts2 零配置 ) convention-plugin 可以用来实现 struts2 的零配置.零配置的意思并不是说没有配置,而是通过约 ...

  4. 阶段1 语言基础+高级_1-3-Java语言高级_04-集合_08 Map集合_7_HashMap存储自定义类型键值

    自定义类型做key值.必须要重写hashCode和equals方法 创建pserson类 有name个age两个成员变量.重写toString方法 key有重复,会被新的value值替换掉. key值 ...

  5. JSP不支持EL表达式的解决方案

    EL的全称是Expression Language.1.在默认情况下,Servlet 2.3 / JSP 1.2是不支持EL表达式的,而Servlet 2.4 / JSP 2.0支持. servlet ...

  6. TNS-01106: Listener using listener name LISTENER has already been started

    -- 启动监听,提示已经启动. [oracle@sh ~]$ lsnrctl startLSNRCTL for Linux: Version 12.1.0.2.0 - Production on 06 ...

  7. C#建造者模式

    /// <summary> /// 电脑类 /// </summary> public class Computer { //电脑组件集合 private IList<s ...

  8. oracle--表空间处理

    CREATE TABLESPACE命令详解(转) 表空间理解 https://www.cnblogs.com/kerrycode/p/3418694.html 常用操作 https://www.cnb ...

  9. [2019杭电多校第三场][hdu6609]Find the answer(线段树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6609 大致题意是求出每个位置i最小需要将几个位置j变为0(j<i),使得$\sum_{j=1}^ ...

  10. Thymeleaf运算符和表达式

    字符串拼接 方式一: <span th:text="'当前是第'+${page}+'页 ,共'+${page}+'页'"></span> 方式二: 使用&q ...