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

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 题意:半圆围绕圆心旋转能够覆盖平面内最多的点
题解:先去掉所有和圆心距离大于r的点,然后我们以每一点和圆心组成的线段为边界来计算线段两边的点,比较出最大值就好了.记得赋值最大值的时候要赋值为0,因为它有可能不会进循环。
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
using namespace std;
const int N = ;
const double eps = 1e-;
struct Point{
double x,y;
}p[N],circle;
struct Line{
Point a,b;
}line;
double r;
int n;
int cross(Point a,Point b,Point c){
double ans = (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y);
if(fabs(ans)<eps) return ;
if(ans<) return ;
return -;
}
int main(){
while(true){
scanf("%lf%lf%lf",&circle.x,&circle.y,&r);
if(r<=) break;
scanf("%d",&n);
int k = ;
for(int i=;i<n;i++){
double x,y;
scanf("%lf%lf",&x,&y);
if((x-circle.x)*(x-circle.x)+(y-circle.y)*(y-circle.y)>r*r) continue;
p[k].x = x;
p[k++].y = y;
}
int temp1 ,temp2,mx = ; ///mx要赋值为0,因为有可能一个点都没有,习惯赋值成-1被坑了一把
for(int i=;i<k;i++){
line.a = p[i];
line.b = circle;
temp1=temp2 =;
for(int j=;j<k;j++){
if(cross(p[j],line.a,line.b)==) {
temp1++;
temp2++;
}else if(cross(p[j],line.a,line.b)==){
temp1++;
}else temp2++;
}
int ans = max(temp1,temp2);
mx = max(ans,mx);
}
printf("%d\n",mx);
}
return ;
}

poj 1106(半圆围绕圆心旋转能够覆盖平面内最多的点)的更多相关文章

  1. Poj 1106 Transmitters

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

  2. html5 canvas围绕中心点旋转

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. Unity摄像机围绕物体旋转两种实现方式

    第一种,使用Transform 函数 RotateAround. 代码如下: public Transform target;//获取旋转目标 private void camerarotate() ...

  4. IOS 以随意点为圆心 旋转UIView

    环绕底边中点旋转                     UIView本身是支持旋转的,能够用UIView.transform属性实现旋转. The origin of the transform i ...

  5. “全栈2019”Java第一百零一章:局部内部类覆盖作用域内成员详解

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

  6. n个点m条有向边,求在入度为零的点到n号点的所有路 //径中,哪条边被这些路径覆盖的次数最多

    //n个点m条有向边,求在入度为零的点到n号点的所有路 //径中,哪条边被这些路径覆盖的次数最多 //有关DAG的知识,先记个模板 #include<iostream> #include& ...

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

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

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

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

  9. poj 3020 Antenna Placement(最小路径覆盖 + 构图)

    http://poj.org/problem?id=3020 Antenna Placement Time Limit: 1000MS   Memory Limit: 65536K Total Sub ...

随机推荐

  1. pycharm的使用二

    一.pycharm设置参数 设置传入程序的参数:Alt+shift+F10 → Edit Configurations → 选中所需要进行设置参数的脚本 → Script parameters:输入设 ...

  2. wireshark 安装

    #yum install wireshark 安装完毕后 whereis wireshark 找不到可执行程序 /bin /sbin /usr/bin /usr/sbin下均没有. 实际上wiresh ...

  3. Tomcat详解及SNS系统的部署实现

    Tomcat详解及SNS系统的部署实现   http://jungege.blog.51cto.com/4102814/1409290

  4. istringstream输入数据到数组

    istringstream iss(line); ; while (!(iss >> dat[n]).fail()) n++;

  5. TO_CHAR 和 TO_DATE的一些用法总结

    对于初学者来说,日期处理那快一向是问题的集中地.今天刚刚看了个案例,将的就是ORACLE日期处理中的错误,其关键原因,就是TO_CHAR 和TO_DATE的用法不清晰,,事实上,这两个东西也特别容易混 ...

  6. python - web自动化测试 - 元素操作 - 窗口切换

    # -*- coding:utf-8 -*- ''' @project: web学习 @author: Jimmy @file: 元素操作-切换.py @ide: PyCharm Community ...

  7. 第一天docker入门

    [01 入门] docker 最核心为三部分组成 镜像,仓库和容器 镜像:一个只读的模板 仓库:代码仓库,镜像的集合 容器:镜像的实例化进程 我们可以这样理解 容器就是一个沙箱,docker利用容器运 ...

  8. windows下vim高亮systemverilog

    主要解决window环境下,vim高亮systemverilog的方法. 第一步:准备材料下载地址:https://files.cnblogs.com/files/aslmer/verilog_sys ...

  9. URAL 1944 大水题模拟

    D - Record of the Attack at the Orbit Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format ...

  10. jQuery中Ajax的属性设置

    1.全局设置为同步 $.ajaxSetup({ async: false });