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. selenium+phantomJS学习使用记录

    背景知识: phantomjs是一个基于webkit的没有界面的浏览器,所以运行起来比完整的浏览器要高效. selenium是一个测试web应用的工具,目前是2.42.1版本,和1版的区别在于2.0+ ...

  2. Java程序编译和运行的过程【转】

    转自:http://www.360doc.com/content/14/0218/23/9440338_353675002.shtml Java整个编译以及运行的过程相当繁琐,本文通过一个简单的程序来 ...

  3. Linux下后台程序完成自动输入密码等交互行为的例子

    今天要开发一个定时任务,然后加入cron列表中.但是有个问题摆在眼前,脚本的执行中需要输入数据库密码: mysql -u root -p << SQL use db; set names  ...

  4. Nagios监控远端的mysql

    工作原理: 利用特定的用户定期访问指定的mysql数据库.当不能访问或连不通时则报警. 1.在生产库上安装nagios插件    安装略    备注:编译完显示一定要有mysql支持,不然没有chec ...

  5. Quartz2D简介及基本线条绘制

    * Quartz2D简介 1.什么是Quartz2D? 他是一个二维的绘图引擎,同时支持iOS和Mac系统 2.Quartz2D能完成的工作 画基本线条,绘制文字,图片,截图,自定义UIView. 3 ...

  6. C#:DataTable内容转换为String(XML)

    //DataTable转String方法 public static String DataTable2String(DataTable dt) { string strXML = "< ...

  7. Java 如何快速序列化

    1,定义变量

  8. Maven invalid task...

    执行maven构建项目报错: Invalid task '‐DgroupId=*': you must specify a valid lifecycle phase, or a goal in th ...

  9. [HTML][服务器]状态码列表status

    AJAX中请求远端文件.或在检测远端文件是否掉链时,都需要了解到远端服务器反馈的状态以确定文件的存在与否. 当然,在我们平常浏览网页时,也会发现一些文件不存在时显示为“404错误”,这就是常见的Htt ...

  10. poj1703 Lost Cows

    给定集合{1,2,...,n}的一个置换,指定每个位置上在其左方且比其小的数的个数,求该置换. 这题我目前还只会O(n^2)的做法. 以后再用更高效的算法解决. http://poj.org/prob ...