poj1106 Transmitters
地址:http://poj.org/problem?id=1106
题目:
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 5405 | Accepted: 2873 |
Description
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
Output
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的更多相关文章
- 【解题报告】POJ-1106 Transmitters
原题地址:http://poj.org/problem?id=1106 题目大意: 给定一些平面的点以及一个圆心和半径,过圆心作一个半圆,求点在半圆中点最多多少个. 解题思路: 首先将给定点中和圆心的 ...
- [ACM_几何] Transmitters (zoj 1041 ,可旋转半圆内的最多点)
Description In a wireless network with multiple transmitters sending on the same frequencies, it is ...
- poj 1106 Transmitters (叉乘的应用)
http://poj.org/problem?id=1106 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4488 A ...
- Poj 1106 Transmitters
Poj 1106 Transmitters 传送门 给出一个半圆,可以任意旋转,问这个半圆能够覆盖的最多点数. 我们枚举每一个点作为必然覆盖点,那么使用叉积看极角关系即可判断其余的点是否能够与其存在一 ...
- ZOJ1041 Transmitters
Transmitters Time Limit: 2 Seconds Memory Limit: 65536 KB In a wireless network with multiple t ...
- POJ 1106 Transmitters(计算几何)
题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...
- ZOJ 1041 Transmitters
原题链接 题目大意:有一个发射站,覆盖范围是半径一定的一个半圆.在一个1000*1000平方米的地盘里有很多接收站.给定发射站的圆心,求最佳角度时能覆盖接收站的个数. 解法:本质上就是给一个原点和其他 ...
- poj 1106 Transmitters (枚举+叉积运用)
题目链接:http://poj.org/problem?id=1106 算法思路:由于圆心和半径都确定,又是180度,这里枚举过一点的直径,求出这个直径的一个在圆上的端点,就可以用叉积的大于,等于,小 ...
- poj1106
极角排序扫一圈. 今天没什么状态写个水题减轻负罪感(大雾) #include <cstdio> #include <cmath> #include <cstring> ...
随机推荐
- linux命令之用户和用户组
知识点: 1.-rwx--x--x (711) 只有所有者才有读,写,执行的权限,组群和其他人只有执行的权限 2.将root用户添加到supergroup用户组 groupadd supergroup ...
- 使用 XPath
XPath 简介: (1) 前面我们爬取一个网页,都是使用正则表达式来提取想要的信息,但是这种方式比较复杂,一旦有一个地方写错,就匹配不出来了,因此我们可以使用 XPath 来进行提取(2) XPat ...
- x86 体系指令
FASM 第二章 - 2.1 x86 体系指令 Author: 徐艺波 From: xuyibo.org Updated: 2008-04-17 官方论坛 本站软件反馈.软件开发交流. ...
- <转>SVM实现之SMO算法
转自http://blog.csdn.net/zouxy09/article/details/17292011 终于到SVM的实现部分了.那么神奇和有效的东西还得回归到实现才可以展示其强大的功力.SV ...
- 正则表达式—RegEx(RegularExpressio)(二)
今日随笔,继续写一些关于正则表达式的东西. 首先补一点昨天的内容: 昨天少说了一个贪婪模式,什么是贪婪模式,比如像+或者*这样的元字符匹配中,会以最大匹配值匹配,这句话是什么意思呢,例如: 定义一个正 ...
- Nginx配置文件(nginx.conf)配置详解[转]
转自:http://blog.csdn.net/tjcyjd/article/details/50695922 重新学习,发觉这篇文章写得很详细就摘录了! Nginx的配置文件nginx.conf配置 ...
- 使用_Capistrano_进行自动化部署(2)
之前的一篇文章是为了解决问题而写的,很多东西都没有介绍清楚,这一篇文章就是完整介绍一下 Capistrano,主要的参考来源是 Modern PHP 这本书. Capistrano 是用于自动部署应用 ...
- 170710、springboot编程之启动器Starter详解
此文系参考网络大牛的,如有侵权,请见谅! Spring Boot应用启动器基本的一共有N(现知道的是44)种:具体如下: 1)spring-boot-starter 这是Spring Boot的核心启 ...
- 电子商务(电销)平台中订单模块(Order)数据库设计明细
电子商务(电销)平台中订单模块(Order)数据库设计明细 - sochishun - 博客园 http://www.cnblogs.com/sochishun/p/7040628.html 电子商务 ...
- Spongebob and Squares---cf599D(数学公式1 + (1+2) + (1+2+3) +....)
题目链接:http://codeforces.com/contest/599/problem/D 一个3×5(m×n)的长方形,里面包含15个边长为1的正方形,有8个边长为2的正方形,有3个边长为3的 ...