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. 部署微软Nano Server的好处是什么?

    虚拟化对数据中心效率和硬件利用率产生了戏剧性的影响,但是接下来有关系统整合的主要责任落 在了操作系统的重量上.虚拟机通常运行企业级操作系统,比如Windows Server,但是Windows Ser ...

  2. 剑指Offer - 九度1516 - 调整数组顺序使奇数位于偶数前面

    剑指Offer - 九度1516 - 调整数组顺序使奇数位于偶数前面2013-11-30 02:17 题目描述: 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部 ...

  3. 《Cracking the Coding Interview》——第4章:树和图——题目6

    2014-03-19 04:16 题目:找出一棵二叉搜索树中的中序遍历后继节点,每个节点都有指针指向其父节点. 解法1:分两种情况:向下走时,先右后左:向上走时,先左后右.如果目标节点有右子树,就向右 ...

  4. 玩转Openstack之Nova中的协同并发(一)

    玩转Openstack之Nova中的协同并发(一) 前不久参加了个Opnstack的Meetup,其中有一个来自EasyStack的大大就Nova中的协同并发做了一番讲解,有所感触,本想当天就总结一下 ...

  5. cookie不能删除

    cookie不仅仅包含一个键值对,还包含域 domain  路径path, 一般domain是请求的地址 www.baidu.com/news.html 那domain就是www.baidu.com ...

  6. TIDB介绍

    TiDB 是什么? TiDB 是一个分布式 NewSQL 数据库.它支持水平弹性扩展.ACID 事务.标准 SQL.MySQL 语法和 MySQL 协议,具有数据强一致的高可用特性,是一个不仅适合 O ...

  7. shell之route命令相关

    使用下面的 route 命令可以查看 Linux 内核路由表. # route Destination Gateway Genmask Flags Metric Ref Use Iface 192.1 ...

  8. [部署开发环境]部署django的生成环境nginx+uwsgi+django

    #教程 # ubuntu部署django项目 # 部署准备 - ubuntu操作系统 -- vagrant虚拟 - Nginx服务器 -- 安装在ubuntu的web服务器 - uWSGI应用协议服务 ...

  9. Client does not support authentication protocol requested by server

    关于由于版本号码不同而引起的 Client does not support authentication protocol requested by server 问题 搜索类似的问题,得到的答案类 ...

  10. XJOI NOIP模拟题1

    第一题 分析: 开始想的是贪心,取每列均值最大一段. 应该是01分数规划,具体看代码 代码: program gold; var a:..]of int64; n,i,m,j,x:longint; f ...