poj 1106 Transmitters (计算几何,叉积||极角排序)
2015-11-09 09:59
555 查看
Transmitters
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.
View Code
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 4817 | Accepted: 2576 |
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.
/************************************************************************* > File Name: code/poj/1106.cpp > Author: 111qqz > Email: rkz2013@126.com > Created Time: 2015年11月09日 星期一 09时28分51秒 ************************************************************************/ #include<iostream> #include<iomanip> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<string> #include<map> #include<set> #include<queue> #include<vector> #include<stack> #include<cctype> #define fst first #define sec second #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define ms(a,x) memset(a,x,sizeof(a)) using namespace std; const double eps = 1E-8; const int dx4[4]={1,0,0,-1}; const int dy4[4]={0,-1,1,0}; typedef long long LL; const int inf = 0x3f3f3f3f; const int N=2E4+7; int n; double r; int dblcmp( double d) { return d<-eps?-1:d>eps; } struct point { double x,y; point(){} point(double _x,double _y): x(_x),y(_y){}; void input() { scanf("%lf %lf",&x,&y); } point operator - (const point &p)const{ return point(x-p.x,y-p.y); } double operator ^(const point &p)const{ return x*p.y-y*p.x; } double dis(point p) { return sqrt((x-p.x)*(x-p.x)+(y-p.y)*(y-p.y)); } }tmp ,c,p ; int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif while (~scanf("%lf %lf %lf",&c.x,&c.y,&r)) { int cnt = 0 ; if (dblcmp(r)<=0) break; scanf("%d",&n); for ( int i = 0 ;i < n ; i ++) { tmp[i].input(); double d =c.dis(tmp[i]); if (dblcmp(d-r)<=0) { //p[cnt]=tmp[i]; p[cnt].x=tmp[i].x; p[cnt].y=tmp[i].y; cnt++; } } int ans = 0; for ( int i = 0 ; i < cnt ; i++) { int sum = 1 ; for ( int j = 0 ; j < cnt ; j++) { double cross = (c-p[i])^(c-p[j]); if (cross>=0&&i!=j) { sum++; } } ans = max(sum,ans); } printf("%d\n",ans); } #ifndef ONLINE_JUDGE #endif fclose(stdin); return 0; }
View Code
相关文章推荐
- 关于WORLD转PDF
- Wireless之无线信道
- Lucene学习总结二
- VIM设置
- 目标检测之LatentSVM和可变形部件模型(Deformable Part Model,DPM)
- js加密解密
- 学习笔记之eclipse中处理js文件报错
- 内存泄露从入门到精通三部曲之基础知识篇
- C#连接内存数据库redis【1、Redis存读取数据】
- synchronized和volatile的使用方法以及区别
- Microsoft JScript 运行时错误: “”未定义
- 手动内存管理(MRC)
- 简易的JQuery设置Cookie
- nodejs中cookie、session的使用
- php的加密解密技术
- 跳表SkipList
- linux下c/c++实例之六时间测试和定时器
- 策略模式和工厂模式的区别
- twemproxy简介-redis和memcache代理服务器
- hadoop2.6源代码编译