(poj step8.1.1.1)POJ 1106 Transmitters(判断一条边在另一条边的哪一个方向——计算叉积)
2013-11-16 11:08
411 查看
/* * POJ_1106.cpp * * Created on: 2013年11月16日 * Author: Administrator */ #include <iostream> #include <cstdio> #include <cmath> using namespace std; const double epsi = 1e-10; const double pi = acos(-1.0); const int maxn = 50005; struct Point{ double x,y; Point(double _x = 0,double _y = 0):x(_x),y(_y){ } Point operator-(const Point& op2)const{//**要注意这种写法 return Point(x - op2.x,y - op2.y); } double operator^(const Point& op2)const{ return x*op2.y - y*op2.x; } }; int sign(const double& x){//判断x是正数还是负数 if(x > epsi){ return 1;//传入的数是一个整数... }else if(x < -epsi){ return -1;//传入的数是一个负数... } return 0; } double sqr(double x){//计算一个数的平方数 return x*x; } double mul(const Point& p0,const Point& p1,const Point& p2){//计算p0p1与p1p2的叉积叉积 return (p1-p0)^(p2-p0); } double dis2(const Point& p0,const Point& p1){//返回两个点的距离的平方 return sqr(p0.x - p1.x) + sqr(p0.y - p1.y); } double dis(const Point& p0,const Point& p1){//返回两个点的距离 return sqrt(dis2(p0,p1)); } int n; Point p[maxn],cp; double r; int main(){ while(scanf("%lf%lf%lf",&cp.x,&cp.y,&r),r >= 0){ scanf("%d",&n); int i; for(i = 0 ; i < n ; ++i){ scanf("%lf%lf",&p[i].x,&p[i].y); } int j; int ans = 0; for(i = 0 ; i < n ; ++i){ int temp = 0 ; for(j = 0 ; j < n ; ++j){ if(sign(dis(p[j],cp) - r) != 1){//如果在辐射范围内 if(sign(mul(cp,p[i],p[j])) != 1){//如果在辐射的一边,这里等于-1也是行的 temp++; } } } ans = max(ans,temp); } printf("%d\n",ans); } return 0; }
相关文章推荐
- POJ 1106 Transmitters(计算几何:叉积)
- poj 1106 Transmitters (计算几何,叉积||极角排序)
- TOYS - POJ 2318(计算几何,叉积判断)
- POJ 2398 Toy Storage [叉积判断+二分查找]【计算几何】
- POJ 1106 Transmitters(计算几何)
- (计算几何POJ step 8.1.1.2)POJ 1654 Area(使用叉积来计算多边形面积)
- POJ 1106 Transmitters(计算几何 极角排序啊)
- (计算几何step8.1.2.1)POJ 2653 Pick-up sticks(判断一根木棒的上面时候还有其他木棒——判断两条直线是否相交)
- poj 1106 Transmitters 计算几何
- POJ 2318 TOYS [叉积判断+二分查找]【计算几何】
- POJ 2318 TOYS (计算几何,叉积判断)
- POJ 1106 Transmitters 计算几何
- POJ 2398 Toy Storage(计算几何,叉积判断点和线段的关系)
- POJ 2398 Toy Storage(计算几何,叉积判断点和线段的关系)
- POJ 1106 Transmitters (简单计算几何)
- (计算几何step8.1.2.2)POJ 1269 Intersecting Lines(使用叉积来计算两条直线的交点)
- POJ 1106 Transmitters(叉积)
- POJ 1127 基础计算几何(判断两线段相交)+并查集
- POJ 1106 Transmitters (几何覆盖问题)
- poj1106---计算几何