地址:http://poj.org/problem?id=1106

题目:

Transmitters
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 5405   Accepted: 2873

Description

In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don't overlap, or at least that they don't conflict. One way of accomplishing this is to restrict a transmitter's coverage area. This problem uses a shielded transmitter that only broadcasts in a semicircle.

A transmitter T is located somewhere on a 1,000 square meter grid. It broadcasts in a semicircular area of radius r. The transmitter may be rotated any amount, but not moved. Given N points anywhere on the grid, compute the maximum number of points that can be simultaneously reached by the transmitter's signal. Figure 1 shows the same data points with two different transmitter rotations. 

All input coordinates are integers (0-1000). The radius is a positive real number greater than 0. Points on the boundary of a semicircle are considered within that semicircle. There are 1-150 unique points to examine per transmitter. No points are at the same location as the transmitter. 

Input

Input consists of information for one or more independent transmitter problems. Each problem begins with one line containing the (x,y) coordinates of the transmitter followed by the broadcast radius, r. The next line contains the number of points N on the grid, followed by N sets of (x,y) coordinates, one set per line. The end of the input is signalled by a line with a negative radius; the (x,y) values will be present but indeterminate. Figures 1 and 2 represent the data in the first two example data sets below, though they are on different scales. Figures 1a and 2 show transmitter rotations that result in maximal coverage.

Output

For each transmitter, the output contains a single line with the maximum number of points that can be contained in some semicircle.

Sample Input

25 25 3.5
7
25 28
23 27
27 27
24 23
26 23
24 29
26 29
350 200 2.0
5
350 202
350 199
350 198
348 200
352 200
995 995 10.0
4
1000 1000
999 998
990 992
1000 999
100 100 -2.5

Sample Output

3
4
4

Source

思路:

  直接枚举

 #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm> using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-; /****************常用函数***************/
//判断ta与tb的大小关系
int sgn( double ta, double tb)
{
if(fabs(ta-tb)<eps)return ;
if(ta<tb) return -;
return ;
} //点
class Point
{
public: double x, y; Point(){}
Point( double tx, double ty){ x = tx, y = ty;} bool operator < (const Point &_se) const
{
return x<_se.x || (x==_se.x && y<_se.y);
}
friend Point operator + (const Point &_st,const Point &_se)
{
return Point(_st.x + _se.x, _st.y + _se.y);
}
friend Point operator - (const Point &_st,const Point &_se)
{
return Point(_st.x - _se.x, _st.y - _se.y);
}
//点位置相同(double类型)
bool operator == (const Point &_off)const
{
return sgn(x, _off.x) == && sgn(y, _off.y) == ;
} }; /****************常用函数***************/
//点乘
double dot(const Point &po,const Point &ps,const Point &pe)
{
return (ps.x - po.x) * (pe.x - po.x) + (ps.y - po.y) * (pe.y - po.y);
}
//叉乘
double xmult(const Point &po,const Point &ps,const Point &pe)
{
return (ps.x - po.x) * (pe.y - po.y) - (pe.x - po.x) * (ps.y - po.y);
}
//两点间距离的平方
double getdis2(const Point &st,const Point &se)
{
return (st.x - se.x) * (st.x - se.x) + (st.y - se.y) * (st.y - se.y);
}
//两点间距离
double getdis(const Point &st,const Point &se)
{
return sqrt((st.x - se.x) * (st.x - se.x) + (st.y - se.y) * (st.y - se.y));
} Point pt[],cr;
double r;
int main(void)
{
while(~scanf("%lf%lf%lf",&cr.x,&cr.y,&r))
{
if(sgn(r,)<) break;
int n,ans=;
scanf("%d",&n);
r*=r;
for(int i=;i<=n;i++)
scanf("%lf%lf",&pt[i].x,&pt[i].y);
for(int i=;i<=n;i++)
if(sgn(getdis2(cr,pt[i]),r)<=)
{
int cnt=;
for(int j=;j<=n;j++)
if(i!=j && sgn(getdis2(cr,pt[j]),r)<= && sgn(xmult(cr,pt[i],pt[j]),)>=)
cnt++;
ans=max(ans,cnt);
}
printf("%d\n",ans);
}
return ;
}

poj1106 Transmitters的更多相关文章

  1. 【解题报告】POJ-1106 Transmitters

    原题地址:http://poj.org/problem?id=1106 题目大意: 给定一些平面的点以及一个圆心和半径,过圆心作一个半圆,求点在半圆中点最多多少个. 解题思路: 首先将给定点中和圆心的 ...

  2. [ACM_几何] Transmitters (zoj 1041 ,可旋转半圆内的最多点)

    Description In a wireless network with multiple transmitters sending on the same frequencies, it is ...

  3. poj 1106 Transmitters (叉乘的应用)

    http://poj.org/problem?id=1106 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4488   A ...

  4. Poj 1106 Transmitters

    Poj 1106 Transmitters 传送门 给出一个半圆,可以任意旋转,问这个半圆能够覆盖的最多点数. 我们枚举每一个点作为必然覆盖点,那么使用叉积看极角关系即可判断其余的点是否能够与其存在一 ...

  5. ZOJ1041 Transmitters

    Transmitters Time Limit: 2 Seconds      Memory Limit: 65536 KB In a wireless network with multiple t ...

  6. POJ 1106 Transmitters(计算几何)

    题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...

  7. ZOJ 1041 Transmitters

    原题链接 题目大意:有一个发射站,覆盖范围是半径一定的一个半圆.在一个1000*1000平方米的地盘里有很多接收站.给定发射站的圆心,求最佳角度时能覆盖接收站的个数. 解法:本质上就是给一个原点和其他 ...

  8. poj 1106 Transmitters (枚举+叉积运用)

    题目链接:http://poj.org/problem?id=1106 算法思路:由于圆心和半径都确定,又是180度,这里枚举过一点的直径,求出这个直径的一个在圆上的端点,就可以用叉积的大于,等于,小 ...

  9. poj1106

    极角排序扫一圈. 今天没什么状态写个水题减轻负罪感(大雾) #include <cstdio> #include <cmath> #include <cstring> ...

随机推荐

  1. NodeJS-002-Expres启动

    1.打开app.js文件 2.在module.exports = app;之前输入: app.listen(8100,function(){ console.log("Server Star ...

  2. python2.0_s12_day19_前端结合后端展示客户咨询纪录

    接下来就是将后台视图与前端页面结合起来了完成后台系统了.实现前端展示用户列表1.先在base.html代码中把模版中Dashboard下面的内容清空,如下: 具体删除哪些html代码,自己找吧.2.我 ...

  3. isdigit()

    isdigit() 是字符串的一个方法,用来判断这个字符串是否是纯数字的字符串 In [1]: str = 'hello' In [2]: str.isdigit() Out[2]: False In ...

  4. iOS 9 分屏多任务:入门(中文版)

    本文转载至 http://www.cocoachina.com/ios/20150714/12555.html 本文由钢铁侠般的卿哥(微博)翻译自苹果官方文档:Adopting Multitaskin ...

  5. MYSQL系列之(二)

    上一篇文章讲的是mysql的基本操作,这一篇会有一点难以理解,本节主要内容mysql视图,存储过程,函数,事务,触发器,以及动态执行sql 视图view 视图是一个虚拟表,其内容由查询定义.同真实的表 ...

  6. filter IE滤镜(Internet Explorer)CSS

    收集一些IE滤镜,留作之后开发用. 透明度 #myElement { opacity: .; /* other browsers */ filter: progid: DXImageTransform ...

  7. ./configure

    ./configure --prefix=/usr/local/scws --prefix选项是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr/local/bin,库文件默认放在/ ...

  8. scss的安装使用

    Ruby的安装 如果是Window系统,请打开:http://rubyinstaller.org/downloads/ ,下载当前稳定版本的exe文件.界面如下所示: Step(2): 接下来,在系统 ...

  9. SignalR实现在线聊天室功能

    一.在线聊天室 1.新建解决方案 SignalROnlineChatDemo 2.新建MVC项目 SignalROnlineChatDemo.Web (无身份验证) 3.安装SignalR PM> ...

  10. postgresql数据库中对重复数据的处理

    我们在使用postgresql数据库的时候,如果一张数据表在未做任何约束的情况下,很可能会出现几条完全一样的数据,即重复数据.如下图所示: 那么如果我们要删除其中的2条该怎么办呢?第一种我们可以清空表 ...