Phone CellTime Limit:10000MS    Memory Limit:32768KB    64bit IO Format:%lld
& %llu

Description

Nowadays, everyone has a cellphone, or even two or three. You probably know where their name comes from. Do you. Cellphones can be moved (they are "mobile") and they use wireless connection to static stations called BTS (Base Transceiver Station). Each BTS
covers an area around it and that area is called a cell.

The Czech Technical University runs an experimental private GSM network with a BTS right on top of the building you are in just now. Since the placement of base stations is very important for the network coverage, your task is to create a program that will
find the optimal position for a BTS. The program will be given coordinates of "points of interest". The goal is to find a position that will cover the maximal number of these points. It is supposed that a BTS can cover all points that are no further than some
given distance R. Therefore, the cell has a circular shape.

The picture above shows eight points of interest (little circles) and one of the possible optimal BTS positions (small triangle). For the given distance
R, it is not possible to cover more than four points. Notice that the BTS does not need to be placed in an existing point of interest.

Input

The input consists of several scenarios. Each scenario begins with a line containing two integer numbers
N and R. N is the number of points of interest, 1 <=
N
<= 2000. R is the maximal distance the BTS is able to cover, 0 <= R < 10000. Then there are
N lines, each containing two integer numbers Xi,
Yi
giving coordinates of the i-th point, |Xi|, |Yi| < 10000. All points are distinct, i.e., no two of them will have the same coordinates.

The scenario is followed by one empty line and then the next scenario begins. The last one is followed by a line containing two zeros.

A point lying at the circle boundary (exactly in the distance R) is considered covered. To avoid floating-point inaccuracies, the input points will be selected in such a way that for any possible subset of points
S that can be covered by a circle with the radius R + 0.001, there will always exist a circle with the radius R that also covers them.

Output

For each scenario, print one line containing the sentence "It is possible to cover M points.", where
M is the maximal number of points of interest that may be covered by a single BTS.

Sample Input

8 2
1 2
5 3
5 4
1 4
8 2
4 5
7 5
3 3 2 100
0 100
0 -100 0 0

Sample Output

It is possible to cover 4 points.
It is possible to cover 2 points.

Notes

The first sample input scenario corresponds to the picture, providing that the X axis aims right and Y axis down.

本来模版中有个n^2算法的。可是超时。赛后百度了一下。还有nlogn算法的。

那么也能够当作模版来用了。

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm> using namespace std ; const double eps = 1e-8 ;
const double PI = acos(-1.0) ;
int n ;
double r ; struct point
{
double x,y ;
}p[2010] ;
struct node
{
double angle ;
int flag ;
}q[4030] ; inline int dcmp(double d)
{
return d < -eps ? -1 : d > eps ;
}
bool cmp(const node &a,const node &b)//角度区间排序
{
if(dcmp(a.angle-b.angle) == 0 ) return a.flag > b.flag ;
return a.angle < b.angle ;
}
double Sqrt(double x)
{
return x*x ;
}
double dist(const point &a,const point &b)
{
return sqrt(Sqrt(a.x-b.x)+Sqrt(a.y-b.y)) ;
} int main()
{
while(~scanf("%d %lf",&n,&r))
{
if(n == 0) break ;
for(int i = 0 ; i < n ; i++)
scanf("%lf %lf",&p[i].x,&p[i].y) ;
int ans = 0 ;
for(int i = 0 ; i < n ; i++)
{
int m = 0 ;
for(int j = 0 ; j < n ; j++)
{
if(i == j) continue ;
double d = dist(p[i],p[j]) ;
if(d > 2*r+0.001) continue ;
double s = atan2(p[j].y-p[i].y,p[j].x-p[i].x) ;
if(s < 0) s += 2*PI ;//角度区间修正
double ph = acos(d/2.0/r) ;//圆心角转区间 q[m++].angle = s - ph + 2*PI ;q[m-1].flag = 1 ;
q[m++].angle = s + ph + 2*PI ;q[m-1].flag = -1 ;
}
sort(q,q+m,cmp) ;
int sum = 0 ;
for(int j = 0 ; j < m ; j++)
{
ans = max(ans,sum += q[j].flag) ; }
}
printf("It is possible to cover %d points.\n",ans+1) ;
}
return 0 ;
}

哈理工2015暑假训练赛 zoj 2078Phone Cell的更多相关文章

  1. 哈理工2015 暑假训练赛 zoj 2976 Light Bulbs

    MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu SubmitStatusid=14946">Practice ...

  2. 哈理工2015暑假集训 zoj 2975 Kinds of Fuwas

    G - Kinds of Fuwas Time Limit:2000MS    Memory Limit:65536KB    64bit IO Format:%lld & %llu Subm ...

  3. 浙江理工2015.12校赛-A

    孙壕请一盘青岛大虾呗 Time Limit: 5 Sec Memory Limit: 128 MB Submit: 577 Solved: 244 Description 话说那一年zstu与gdut ...

  4. 浙江理工2015.12校赛-F Landlocked

    Landlocked Time Limit: 5 Sec Memory Limit: 128 MB Submit: 288 Solved: 39 Description Canada is not a ...

  5. 浙江理工2015.12校赛-G Jug Hard

    Jug Hard Time Limit: 10 Sec Memory Limit: 128 MB Submit: 1172 Solved: 180 Description You have two e ...

  6. 浙江理工2015.12校赛-B 七龙珠

    七龙珠 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 781 Solved: 329 Description 话说孙壕请吃了青岛大虾后,一下子变穷了,就 ...

  7. 2015暑假训练(UVALive 5983 - 5992)线段树离线处理+dp

    A: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=83690#problem/A 题意:N*M的格子,从左上走到右下,要求在每个点的权值 ...

  8. [置顶] 2013_CSUST暑假训练总结

    2013-7-19 shu 新生训练赛:母函数[转换成了背包做的] shuacm 题目:http://acm.hdu.edu.cn/diy/contest_show.php?cid=20083总结:h ...

  9. 暑假训练round 3 题解

    今天做题运气出奇的好,除了几处小错误调试之后忘记改掉了……最后还AK了……虽然题目不难,学长也说是福利局,但是对个人的鼓励作用还是挺大的……至此暑假训练就结束了,也算没有遗憾……. 题解如下: Pro ...

随机推荐

  1. android:QQ多种側滑菜单的实现

    在这篇文章中写了 自己定义HorizontalScrollView实现qq側滑菜单 然而这个菜单效果仅仅是普通的側拉效果 我们还能够实现抽屉式側滑菜单 就像这样 第一种效果 另外一种效果 第三种效果 ...

  2. ChrisRenke/DrawerArrowDrawable源代码解析

    转载请注明出处http://blog.csdn.net/crazy__chen/article/details/46334843 源代码下载地址http://download.csdn.net/det ...

  3. Android应用之——自己定义控件ToggleButton

    我们经常会看到非常多优秀的app上面都有一些非常美丽的控件,用户体验非常好.比方togglebutton就是一个非常好的样例,IOS系统以下那个精致的togglebutton现在在android以下也 ...

  4. angularjs1-路由

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  5. php静态函数的使用场景

    php静态函数的使用场景 场景 代码 <?php class Conductor{ public static $i = 100; public function sold(){ $a = se ...

  6. Oracle中的数据字典技术及常用数据字典总结

    一.Oracle数据字典 数据字典是Oracle存放有关数据库信息的地方,其用途是用来描述数据的.比如一个表的创建者信息,创建时间信息,所属表空间信息,用户访问权限信息等.当用户在对数据库中的数据进行 ...

  7. MEF example code

    public interface IObjectResolver { } public class ObjectResolver:IObjectResolver { private Compositi ...

  8. TextView 限制最大行数、最小行数、字数超过“...”表示

    最小行数: android:minLines = "2" //最小行数为2 最大行数: android:maxLines = "2" //最大行数为2 文字超过 ...

  9. 玩转 sublime3 第一弹 文件介绍

    安装 官网下载地址:http://www.sublimetext.com/3 本文将以Windows 64 bit 进行讲解. 目录介绍 sublime默认安装之后会生成一个安装目录和数据目录: C: ...

  10. ZBrush软件特性之Color调控板

    ZBrush®中的Color调色板显示当前颜色并提供数值的方法选择颜色,而且选择辅助色,使用描绘工具可以产生混合的色彩效果. ZBrush 4R8下载:http://wm.makeding.com/i ...