POJ 1106

先判断是否在圆内,然后用叉积判断是否在180度内。枚举判断就可以了。。。

感觉是数据弱了。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
const double eps=0.00000001;
struct point{
	double x,y;
}p[1050],circle;
double rad;
int n,ans;

double dist(double x1,double y1, double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

bool multi(point a,point b){
	if((a.x-circle.x)*(b.y-circle.y)-(a.y-circle.y)*(b.x-circle.x)>=0)
	return true;
	return false;
}

void slove(){
	int tmp;
	for(int i=0;i<n;i++){
		tmp=0;
		for(int j=0;j<n;j++){
			if(multi(p[i],p[j])){
				tmp++;
			}
		}
		if(tmp>ans) ans=tmp;
	}
}

int main(){
	int ni; double x,y;
	while(scanf("%lf%lf%lf",&circle.x,&circle.y,&rad)!=EOF){
		if(rad<0) break;
		scanf("%d",&ni); n=0;
		for(int i=0;i<ni;i++){
			scanf("%lf%lf",&x,&y);
			if(dist(x,y,circle.x,circle.y)<=rad){
				p[n].x=x; p[n].y=y;
				n++;
			}
		}
	//	cout<<n<<endl;
		if(rad==0) { printf("0\n"); continue; }
		ans=0;
		slove();
		printf("%d\n",ans);
	}
	return 0;
}

  

POJ 1106,布布扣,bubuko.com

时间: 2024-12-15 15:14:25

POJ 1106的相关文章

poj 1106 Transmitters (叉乘的应用)

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

poj 1106 Transmitters (计算几何,叉积||极角排序)

Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4817   Accepted: 2576 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

poj 1106 Transmitters

题意:给定一个点的坐标和一个圆半径,一个整数n,然后n个点坐标,求以给定点所在半圆能包含的最多点的个数: 思路:枚举半圆直径边界,统计该边界一侧的包含点数,更新最大值: 技巧:使用叉积,能方便的判断两向量的夹角是否小于180度: #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const double epsi=1e-10;

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

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

POJ 1106 Transmitters(计算几何:叉积)

传送门 Transmitters Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5088 Accepted: 2686 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

[转] POJ几何分类

转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板很重要,模板必须高度可靠.3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面大部分是模板.如果代码一片混乱,那么会严重影响做题正确率.4.注意精度控制.5.能用整数的地方尽量用整数,要想到扩大数据的方法(扩大一倍,或扩大sqrt2).因为整数不用考虑浮点误差,而且运算比浮点快. 一.点

【转】计算几何题目推荐

打算转下来好好做计算几何了. 原文地址:http://blog.sina.com.cn/s/blog_49c5866c0100f3om.html 其实也谈不上推荐,只是自己做过的题目而已,甚至有的题目尚未AC,让在挣扎中.之所以推荐计算几何题,是因为,本人感觉ACM各种算法中计算几何算是比较实际的算法,在很多领域有着重要的用途计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板很重要,模板必须高度可靠.3.要注意代码的组织,因为计算几何的题目很容易上两百行

POJ 题目1106 Transmitters(数学几何)

Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4756   Accepted: 2538 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

POJ 3449 Geometric Shapes --计算几何,线段相交

题意: 给一些多边形或线段,输出与每一个多边形或线段的有哪一些多边形或线段. 解法: 想法不难,直接暴力将所有的图形处理成线段,然后暴力枚举,相交就加入其vector就行了.主要是代码有点麻烦,一步一步来吧. 还有收集了一个线段旋转的函数. Vector Rotate(Point P,Vector A,double rad){ //以P为基准点把向量A旋转rad return Vector(P.x+A.x*cos(rad)-A.y*sin(rad),P.y+A.x*sin(rad)+A.y*co