题意   就是找到一个 位置 使得路由器可以覆盖所有英雄    可以不覆盖主人自己, 找到距离 主人房子最近的位置,距离为多少

没想到  其实是道水题啊!!  分三个情况讨论

第一个情况    如果  把主人的位置放上路由器 可以 覆盖到所有英雄,则答案出来了 0( 一个 半径为 d 的圆,边界上没有点);

第二个情况    考虑  圆上只有一个点,这个圆只受到该点的约束( 则圆心在  连线上);

第三个情况   两个点  或者更多点确定那个圆, 则当两个点或者更多的点都距离为d 时确定那个圆心;因为如果那个点的距离没有到d   证明我还可以更靠近一点房子

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<functional>
#define eps 1e-9
using namespace std;
const double PI = acos( -1.0 );
inline int dcmp( double x ){if( abs(x) < eps )return ;else return x<?-:;}
struct point{
double x,y;
point( double x = ,double y = ):x(x),y(y){}
}node[];
typedef point Vector;
typedef vector<point>ploygon;
inline point operator+( point a,point b ){ return point(a.x+b.x,a.y+b.y); }
inline point operator-( point a,point b ){ return point(a.x-b.x,a.y-b.y); }
inline point operator*( point a,double p){ return point(a.x*p,a.y*p); }
inline point operator/( point a,double p){ return point(a.x/p,a.y/p); }
inline bool operator< ( const point &a,const point &b ){return a.x<b.x||(a.x==b.x&&a.y<b.y);}
inline bool operator==( const point &a,const point &b ){return (dcmp(a.x-b.x) == && dcmp(a.y-b.y) == );}
inline bool operator!=( const point &a,const point &b ){return a==b?false:true;} inline double Dot( point a,point b ){ return a.x*b.x + a.y*b.y; }
inline double Cross( point a,point b ){ return a.x*b.y - a.y*b.x; }
inline double Length( point a ){ return sqrt(Dot(a,a)); }
inline double Angle( point a,point b ){
double right = Dot(a,b)/Length(a)/Length(b);
return acos(right);
}
inline point Rotate( point a,double rad ){
return point( a.x*cos(rad)-a.y*sin(rad),a.x*sin(rad+a.y*cos(rad)) );
}
point A[]; int N; double dis;
bool work( point temp )
{
for( int i = ; i <= N; i++ )
if( Length( A[i]-temp ) > dis && abs(Length( A[i] - temp ) - dis) > eps ){
return false;}
return true;
}
int main( )
{
//freopen( "ou.txt","r",stdin);
//freopen( "in.txt","w",stdout);
while( scanf("%lf%lf%lf",&A[].x,&A[].y,&dis) != EOF )
{
scanf("%d",&N);
for( int i = ; i <= N; i++ )
scanf("%lf%lf",&A[i].x,&A[i].y);
double Max = (<<); bool fell = false;
for( int i = ; i <= N; i++ )
if( Length( A[]-A[i] ) > dis )fell = true;
if( !fell ){ puts("0.00");continue;}
double Min = (<<);
for( int i = ; i <= N; i++ ){
point temp = A[i] + (A[] - A[i])*(dis/Length(A[]-A[i]));
if( Length( temp-A[] ) < Min ) if( work( temp ) )
Min = min( Min,Length(temp-A[]) );
}
for( int i = ; i <= N; i++ )
for( int j = i+; j <= N; j++ )
{
point temp = (A[i]+A[j])/2.0; double D = Length(A[i]-A[j])*0.5;
Vector now1 = Rotate( (A[i]-A[j]),PI/2.0 )*sqrt(dis*dis-D*D)/(D*2.0);
Vector now2 = Rotate( (A[i]-A[j]),-PI/2.0 )*sqrt(dis*dis-D*D)/(D*2.0);
point temp1 = temp + now1;
point temp2 = temp + now2;
if( Length( temp1-A[] ) < Min ) if( work( temp1 ) )
Min = min( Min,Length(temp1-A[]) );
if( Length( temp2-A[] ) < Min ) if( work( temp2 ) )
Min = min( Min,Length(temp2-A[]) );
}
if( Min == (<<) )puts("X");
else printf("%.2lf\n",Min);
}
return ;
}
/* 2600 10712 5075
1
26869 21003 */

HDU 4766 Network的更多相关文章

  1. HDU 2460 Network(双连通+树链剖分+线段树)

    HDU 2460 Network 题目链接 题意:给定一个无向图,问每次增加一条边,问个图中还剩多少桥 思路:先双连通缩点,然后形成一棵树,每次增加一条边,相当于询问这两点路径上有多少条边,这个用树链 ...

  2. HDU 3078 Network(LCA dfs)

    Network [题目链接]Network [题目类型]LCA dfs &题意: 给出n个点的权值,m条边,2种操作 0 u num,将第u个点的权值改成num k u v,询问u到v这条路上 ...

  3. HDU 2460 Network(桥+LCA)

    http://acm.hdu.edu.cn/showproblem.php?pid=2460 题意:给出图,求每次增加一条边后图中桥的数量. 思路: 先用tarjan算法找出图中所有的桥,如果lowv ...

  4. HDU 2460 Network 傻逼Tarjan

    Network Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  5. HDU 2676 Network Wars 01分数规划,最小割 难度:4

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1676 对顶点i,j,起点s=1,终点t=n,可以认为题意要求一组01矩阵use ...

  6. HDU 3078 Network

    简单的  RMQ:  先预处理得到  所有 节点的 公共祖先  和  dfs 得到所有节点的父亲节点:  然后  询问时,从自己出发向上找父亲, 然后  得到所有的节点:排序一下 不知道  这题这样也 ...

  7. HDU 3078 Network LCA

    题意:n个点 m个询问,下面一行是n 个点的权值 再下面n-1行是双向的边 然后m个询问:k u v 若k==0,则把u点的权值改为v,否则回答u->v之间最短路经过点的权值中  第k大的值是多 ...

  8. hdu 3078 Network (暴力)+【LCA】

    <题目链接> 题目大意:给定一颗带点权的树,进行两种操作,k=0,更改某一点的点权,k!=0,输出a~b路径之间权值第k大的点的点权. 解题分析:先通过RMQ的初始化,预处理pre[]数组 ...

  9. HDU 2460 Network 边双连通分量 缩点

    题意: 给出一个无向连通图,有\(m\)次操作,每次在\(u, v\)之间加一条边,并输出此时图中桥的个数. 分析: 先找出边双连通分量然后缩点得到一棵树,树上的每条边都输原图中的桥,因此此时桥的个数 ...

随机推荐

  1. Yarn上的几个问题整理

    原文链接   http://xiguada.org/yarn_some_question/ ‎   1. NodeManager是如何Kill掉Container的呢? 答,在DefaultConta ...

  2. 百度首页html代码

          把百度设为主页 关于百度 About Baidu ©2015 Baidu 使用百度前必读 意见反馈 京ICP证030173号

  3. 【重走Android之路】【开篇】序

    [重走Android之路][开篇]   [序]         本人Nodin,偶尔也叫MoNodin,朋友们都喜欢叫我丁,还有个笔名叫陌上幽人,文艺时叫恋风,发奋时叫不肯腐烂的土壤...也许你觉得我 ...

  4. DWR3.0 dwr 返回值(数组,集合,Map)

    首先导入项目所需要的包,如下:dwr.jar,commons-logging-1.0.4.jar,版本可以调整 1.web.xml<?xml version="1.0" en ...

  5. BI

    http://www.cnblogs.com/biwork/p/3276455.html http://www.cnblogs.com/biwork/p/3328879.html http://www ...

  6. 【周全考虑】CodeForces 245B——Internet Address

    来源:点击打开链接 看上去很简单的一道题,可是错的次数却不少. 题目要求是将一串字母转化成网址——形如格式http(ftp)://xxx.ru/xxxx的样子,看上去很简单,可是还是很容易出错. 刚开 ...

  7. Oracle —— 表结构相关的SQL

    1.表基本信息(Table) select * from user_tables t, user_tab_comments c where c.table_name = t.table_name an ...

  8. java double保留小数点的零的问题,java保留小数点问题

    1.用DecimalFormat格式化,DecimalFormat df=new DecimalFormat("0.00"); System.out.println(df.form ...

  9. vi 每日练习

    vi 1.    4 空格 2.    ctrl + b, ctrl + f 3.     0 $ 4.    1G gg G 5.    10G 6.    10 回车 7.    / ? 8.   ...

  10. 3D场景优化

    一) 有效的性能评测 对于任何一个3D应用程序来说,追求场景画面真实感是一个无止尽的目标,其结果就是让我们的场景越来越复杂,模型更加精细,这必然给图形硬件带来极大的负荷以致于无法达到实时绘制帧率.因此 ...