poj1106
极角排序扫一圈。
今天没什么状态写个水题减轻负罪感(大雾)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
typedef double db;
const db eps = 1e-;
const db pi = acos(-);
int sign(db k){
if (k>eps) return ; else if (k<-eps) return -; return ;
}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point{
db x,y,ang;
point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
point operator * (db k1) const{return (point){x*k1,y*k1};}
point operator / (db k1) const{return (point){x/k1,y/k1};}
int operator == (const point &k1) const{return cmp(x,k1.x)==&&cmp(y,k1.y)==;}
db abs(){ return sqrt(x*x+y*y);}
db dis(point k1){return ((*this)-k1).abs();}
db getw(){return atan2(y,x);}
};
struct circle{
point o;db r;
int inside(point k){return cmp(r,o.dis(k))>=;}
}c;
vector<point> v;
bool cmp2(point a,point b){
return a.ang<b.ang;
}
int n;point t;
int main(){
while (scanf("%lf%lf%lf",&c.o.x,&c.o.y,&c.r)&&c.r>){
//scanf("%lf%lf%lf",&c.o.x,&c.o.y,&c.r);
scanf("%d",&n);
while (n--){
scanf("%lf%lf",&t.x,&t.y);
if(c.inside(t)){
t.ang = (c.o-t).getw();
v.push_back(t);
v.push_back({t.x,t.y,t.ang+*pi});
}
}
sort(v.begin(),v.end(),cmp2);
int m = v.size()/;
int ans = ;
for(int l=,r=;l<m;l++){
while (r<*m&&v[r].ang-v[l].ang<=pi)
r++;
ans=max(ans,r-l);
}
printf("%d\n",ans);
v.clear();
}
}
poj1106的更多相关文章
- 【解题报告】POJ-1106 Transmitters
原题地址:http://poj.org/problem?id=1106 题目大意: 给定一些平面的点以及一个圆心和半径,过圆心作一个半圆,求点在半圆中点最多多少个. 解题思路: 首先将给定点中和圆心的 ...
- poj1106 Transmitters
地址:http://poj.org/problem?id=1106 题目: Transmitters Time Limit: 1000MS Memory Limit: 10000K Total S ...
随机推荐
- 计算 $\dps{\int_0^\infty\frac{\sin^2x}{x^2}dx=\frac{\pi}{2}}$
计算 $\dps{\int_0^\infty\frac{\sin^2x}{x^2}dx=\frac{\pi}{2}}$. 由分部积分, $$\bee\label{1}\bea \int_0^\inft ...
- LinQ简单增、删、改、查
一.简单介绍 1.LinQ to Sql类(NET Language Integrated Query (LINQ) ) LINQ定义了大约40个查询操作符,如select.from.in.where ...
- spring和mybatis的整合开发(基于MapperFactoryBean的整合开发(方便简单不复杂))
MapperFactoryBean是mybati-spring团队提供的一个用于根据mapper接口生成mapper对象的类. 在spring配置文件中可以配置以下参数: 1.mapperInterf ...
- Ubuntu里设置python默认版本为python3(转载)
0 - 步骤 在命令行中执行下述命令: sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 sudo ...
- OSI七层模型与TCP/IP五层模型
博主是搞是个FPGA的,一直没有真正的研究过以太网相关的技术,现在终于能静下心学习一下,希望自己能更深入的掌握这项最基本的通信接口技术.下面就开始搞了. 一.OSI参考模型 今天我们先 ...
- 关于NB-IoT的十大问题和答案【转】
转自:https://blog.csdn.net/u011943791/article/details/80287053 今天大白来给各位解答一下关于NB-IoT的十大问题. 问1:NB-IoT模块还 ...
- 1.2低级线程处理API
并行扩展库相当有用,因为它允许使用更高级的抽象——任务,而不必直接和线程打交道.但有的时候,要处理的代码是在TPL和PLINQ问世(.NET4.0)之前写的.也有可能某个编程问题不能直接使用它们解决, ...
- (初)Knockout 监控属性(Observables)
1 创建带有监控属性的view model 1.1 Observables Knockout是在下面三个核心功能是建立起来的: 监控属性(Observables)和依赖跟踪(Dependency tr ...
- 图片纯前端JS压缩的实现
一.图片上传前端压缩的现实意义 对于大尺寸图片的上传,在前端进行压缩除了省流量外,最大的意义是极大的提高了用户体验. 这种体验包括两方面: 由于上传图片尺寸比较小,因此上传速度会比较快,交互会更加流畅 ...
- LCA最近公共祖先
不会 准备研究一波!!! #include<bits/stdc++.h> ; using namespace std; vector<int> g[maxn]; ][maxn] ...