题目链接:http://poj.org/problem?id=1106

算法思路:由于圆心和半径都确定,又是180度,这里枚举过一点的直径,求出这个直径的一个在圆上的端点,就可以用叉积的大于,等于,小于0判断点在直径上,左,右。 这里要记录直径两边的加直径上的点的个数,去最大的。

代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; const double eps = 1e-;
const double PI = acos(-1.0);
const double INF = 1000000000000000.000; struct Point{
double x,y;
Point(double x=, double y=) : x(x),y(y){ } //构造函数
};
typedef Point Vector; struct Circle{
Point c;
double r;
Circle() {}
Circle(Point c,double r): c(c),r(r) {}
};
Vector operator + (Vector A , Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator - (Vector A , Vector B){return Vector(A.x-B.x,A.y-B.y);}
Vector operator * (double p,Vector A){return Vector(A.x*p,A.y*p);}
Vector operator / (Vector A , double p){return Vector(A.x/p,A.y/p);} bool operator < (const Point& a,const Point& b){
return a.x < b.x ||( a.x == b.x && a.y < b.y);
} int dcmp(double x){
if(fabs(x) < eps) return ;
else return x < ? - : ;
}
bool operator == (const Point& a, const Point& b){
return dcmp(a.x - b.x) == && dcmp(a.y - b.y) == ;
} ///向量(x,y)的极角用atan2(y,x);
inline double Dot(Vector A, Vector B){ return A.x*B.x + A.y*B.y; }
inline double Length(Vector A) { return sqrt(Dot(A,A)); }
inline double Angle(Vector A, Vector B) { return acos(Dot(A,B) / Length(A) / Length(B)); }
double Cross(Vector A, Vector B) { return A.x*B.y - A.y * B.x; }
Vector vecunit(Vector v){ return v / Length(v);} //单位向量 Point read_point(){
Point A;
scanf("%lf %lf",&A.x,&A.y);
return A;
} //多边形
//求面积
double PolygonArea(Point* p,int n){ //n个点
double area = ;
for(int i=;i<n-;i++){
area += Cross(p[i]-p[],p[i+]-p[]);
}
return area/;
} /*************************************分 割 线*****************************************/ int main()
{
//freopen("E:\\acm\\input.txt","r",stdin); Point O,P[];
double R; while(scanf("%lf %lf %lf",&O.x,&O.y,&R) == && dcmp(R)>)
{
int N;
cin>>N;
int cnt = ;
for(int i=;i<=N;i++)
{
Point temp = read_point();
double len = Length(temp-O);
if(dcmp(len-R) > ) continue;
P[++cnt] = temp;
}
int ans = ;
for(int i=; i<=cnt; i++)
{
if(P[i] == O)
{
ans = max(ans,);
continue;
}
int lnum = ;
int rnum = ;
Vector v = P[i] - O;
v = (-1.0)*vecunit(v);
Point T = O + R*v;
for(int j=; j<=cnt; j++)
{
if(i == j) continue;
if(dcmp(Cross(P[j]-T,O-T)) > ) lnum++;
else if(dcmp(Cross(P[j]-T,O-T)) == ) lnum++,rnum++;
else rnum++;
} int num = max(lnum,rnum);
ans = max(ans,num);
}
printf("%d\n",ans);
}
}

poj 1106 Transmitters (枚举+叉积运用)的更多相关文章

  1. Poj 1106 Transmitters

    Poj 1106 Transmitters 传送门 给出一个半圆,可以任意旋转,问这个半圆能够覆盖的最多点数. 我们枚举每一个点作为必然覆盖点,那么使用叉积看极角关系即可判断其余的点是否能够与其存在一 ...

  2. poj 1106 Transmitters (叉乘的应用)

    http://poj.org/problem?id=1106 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4488   A ...

  3. POJ 1106 Transmitters(计算几何)

    题目链接 切计算几何,感觉计算几何的算法还不熟.此题,枚举线段和圆点的直线,平分一个圆 #include <iostream> #include <cstring> #incl ...

  4. poj 1873 凸包+枚举

    The Fortified Forest Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6198   Accepted: 1 ...

  5. POJ 3304 Segments【叉积】

    题意:有n条线段,问有没有一条直线使得所有线段在这条直线上的投影至少有一个共同点. 思路:逆向思维,很明显这个问题可以转化为是否有一条直线穿过所有线段,若有,问题要求的直线与该直线垂直,并且公共点为垂 ...

  6. POJ 1018 【枚举+剪枝】.cpp

    题意: 给出n个工厂的产品参数带宽b和价格p,在这n个工厂里分别选1件产品共n件,使B/P最小,其中B表示n件产品中最小的b值,P表示n件产品p值的和. 输入 iCase n 表示iCase个样例n个 ...

  7. POJ 3977 折半枚举

    链接: http://poj.org/problem?id=3977 题意: 给你n个数,n最大35,让你从中选几个数,不能选0个,使它们和的绝对值最小,如果有一样的,取个数最小的 思路: 子集个数共 ...

  8. poj 1269 Intersecting Lines——叉积求直线交点坐标

    题目:http://poj.org/problem?id=1269 相关知识: 叉积求面积:https://www.cnblogs.com/xiexinxinlove/p/3708147.html什么 ...

  9. poj 2318 TOYS &amp; poj 2398 Toy Storage (叉积)

    链接:poj 2318 题意:有一个矩形盒子,盒子里有一些木块线段.而且这些线段坐标是依照顺序给出的. 有n条线段,把盒子分层了n+1个区域,然后有m个玩具.这m个玩具的坐标是已知的,问最后每一个区域 ...

随机推荐

  1. Objective-C发展历史

    Objective-C发展历史 苹果图标由来: 被咬了一口苹果的LOGO是为了纪念计算机科学的创始人阿兰· 麦席森· 图灵.当年图灵由于身为同性恋者,被强行 "治疗",在被迫注射大 ...

  2. C# 执行批处理文件(*.bat)的方法代码

    代码如下: static void Main(string[] args){    Process proc = null;    try    {                        st ...

  3. 中文翻译:pjsip教程(一)之PJNATH简介

    在学习pjsip的过程中,发现只是单单的阅读英文官方文档,对于里边概念的理解还是不够透彻,并且苦于pjsip没有发现全一点的中文版本,所以想尽自己所能为建设和谐社会而贡献一份力量,文中定会有所疏漏,希 ...

  4. php日期处理

    $datetime=strtotime(date("Y-m-d",time()));//获取当前日期并转换成时间戳 $datetime=$datetime+86400;//在时间戳 ...

  5. Linux系统性能分析工具

    1.  uptime 2.  htop 3. mpstat 4 . iostat 5. dstat 6. netstat 7. tcpdump 8. sar

  6. React Native:使用 JavaScript 构建原生应用 详细剖析

    数月前,Facebook 对外宣布了正在开发的 React Native 框架,这个框架允许你使用 JavaScript 开发原生的 iOS 应用——就在今天,Beta 版的仓库释出了! 基于 Pho ...

  7. python【第十二篇下】操作MySQL数据库以及ORM之 sqlalchemy

    内容一览: 1.Python操作MySQL数据库 2.ORM sqlalchemy学习 1.Python操作MySQL数据库 2. ORM sqlachemy 2.1 ORM简介 对象关系映射(英语: ...

  8. Mac系统安装Lua(转)

    下载最新版的lua请点击,然后解压 运行“终端”进入到该文件夹下 ,主要是cd [文件夹名] 在“终端”输入 make macosx (回车) 在“终端”输入 make test (回车) 然后再输入 ...

  9. javascript学习代码--点击按钮显示内容

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. 流形学习(manifold learning)的一些综述

    流形学习(manifold learning)的一些综述 讨论与进展 issue 26 https://github.com/memect/hao/issues/26 Introduction htt ...