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

Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 4488   Accepted: 2379

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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define eps 1e-6
typedef struct point
{
double x,y;
}point; bool dy(double x,double y){ return x>y+eps; }
bool xy(double x,double y){ return x<y-eps; }
bool dyd(double x,double y){ return x>y-eps; }
bool xyd(double x,double y){ return x<y+eps; }
bool dd(double x,double y){ return fabs(x-y)<eps; } double crossProduct(point a,point b,point c)
{
return (c.x-a.x)*(b.y-a.y)-(c.y-a.y)*(b.x-a.x);
} double dist(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
} point c[];
double st,en,ri;
point tmp;
int solve(int n)
{
int ans;
int maxx=;
for(int i=;i<n;i++)
{
ans=;
for(int j=;j<n;j++)
{
if(i!=j&&dyd(crossProduct(tmp,c[i],c[j]),0.0))
{
ans++;
}
}
if(ans>maxx)
{
maxx=ans;
//ans=0;
}
}
return maxx;
} int main()
{
int n;
double a,b;
while(scanf("%lf%lf%lf",&st,&en,&ri)!=EOF&&ri>=)
{
point p;
tmp.x=st;
tmp.y=en;
scanf("%d",&n);
int cas=;
for(int i=;i<n;i++)
{
scanf("%lf%lf",&p.x,&p.y);
if(xyd(dist(tmp,p),ri))
{
c[cas++]=p;
}
}
printf("%d\n",solve(cas));
}
}

poj 1106 Transmitters (叉乘的应用)的更多相关文章

  1. Poj 1106 Transmitters

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

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

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

  3. POJ 1106 Transmitters(计算几何)

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

  4. POJ 2318 TOYS (叉乘判断)

    <题目链接> 题目大意: 给出矩形4个点和n个挡板俩顶点的位置,这n个挡板将该矩形分成 n+1块区域,再给你m个点的坐标,然你输出每个区域内有几个点. 解题思路: 用叉乘即可简单判断点与直 ...

  5. poj 1106(半圆围绕圆心旋转能够覆盖平面内最多的点)

    Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4955   Accepted: 2624 Desc ...

  6. TOYS POJ 2318 计算几何 叉乘的应用

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15060   Accepted: 7270 Description Calc ...

  7. POJ 1106

    先判断是否在圆内,然后用叉积判断是否在180度内.枚举判断就可以了... 感觉是数据弱了.. #include <iostream> #include <cstdio> #in ...

  8. [转] POJ计算几何

    转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板 ...

  9. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

随机推荐

  1. 视频处理控件TVideoGrabber视频捕捉设设备相关问题

    选择一个视频捕捉设备 首先设置 VideoSource = vs_VideoCaptureDevice来选择一个视频捕捉设备作为一个视频源. 通过指定VideoDevice属性来选择当前的视频捕捉设备 ...

  2. Terminal的快捷键 for Terminal for Mac OS 10.10, Linux/GNU(Ubuntu, deepin, elementory os,CentOS)

    对于习惯用windows键盘的,突然转成Mac蓝牙键盘真的有点不习惯,尤其是多了⌘这个键,还有Alt键也成了Option 但是对于Windows下熟悉的快捷键,它们真的失效了,还好Ubuntu也常用, ...

  3. zabbix源码安装

    Zabbix通过C/S模式采集数据,通过B/S模式在web端展示和配置. 被监控端:主机通过安装agent方式采集数据,网络设备通过SNMP方式采集数据 Server端:通过收集SNMP和agent发 ...

  4. Android常见面试题目

    1.Activity 的生命周期 转自:http://kb.cnblogs.com/page/70125/ 多谢楼主分享 首先看一下Android api中所提供的Activity生命周期图(不明白的 ...

  5. 【PHP设计模式 09_ZhuangShiQi.php】装饰器模式 (decorator)

    <?php /** * [装饰器模式 (decorator)] * 有时候发布一篇文章需要经过很多人手,层层处理 */ header("Content-type: text/html; ...

  6. 微信支付 APP 支付方式的服务器端处理程序

    对于微信的APP的支付,客户服务说只能通过微信开放平台申请.后来在公众帐号确实发现了证据:  微信支付在申请的时候就比较严(麻烦),对服务类的一些支付,本来商品就是虚拟的,所以需要将商品描述的比较详细 ...

  7. PostgreSQL的 Slony-I 数据同步

    原文--http://www.tuicool.com/articles/mMvARf 先谈谈slony的局限性: 1. DDL动作是不会被复制到: 2. 如果想使用slony来同步数据,表必须是带有主 ...

  8. jquery 当前链接激活传递参数|div的切换显示

    一.链接激活时传递参数 $("a").click(function(){ var obj=$(this).attr("field"); //获取当前field ...

  9. css常用命名规则

    (一)常用的CSS命名规则 头:header 内容:content/container 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrappe ...

  10. [HTML]background-size可以缩放大小

    转自:http://www.igooda.cn/jsdt/20130827355.html background-size需要两个值,它的类型可以是像素(px).百分比(%)或是auto,还可以是co ...