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 ...
随机推荐
- Elasticsearch 6.4基本操作 - Java版
1. Elasticsearch Java API有四类client连接方式 TransportClient RestClient Jest Spring Data Elasticsearch 其中T ...
- 第五节:从源码的角度理解各种Result(ActionResult、JsonResult、JavaScriptResult等)
一. 背景 提到MVC不得不说MVC中的各种Result,这些高度封装的xxxResult以及在xxxResult再度封装的xxx,大大提高了MVC框架的开发效率. 相信做过MVC开发的朋友都会用到过 ...
- [再寄小读者之数学篇](2014-06-22 求导数 [中国科学技术大学2014年高等数学B考研试题])
设 $f(x)=x^2\ln(x+1)$, 求 $f^{(n)}(0)$. 解答: 利用 Leibniz 公式易知 $f'(0)=f''(0)=0$, $f^{(n)}(0)=(-1)^{n-3} n ...
- 33. Springboot 系列 原生方式引入Redis,非RedisTemplate
0.pom.xml <dependency> <groupId>redis.clients</groupId> <artifactId>jedis&l ...
- windows下 cmd 界面的替代者 cmder 推荐!
介绍 http://cmder.net/ Portable console emulator for Windows Cmder is a software package created out o ...
- Django之验证码
一.自己生成验证码 二.极验科技互动验证码 使用前步骤:下载官网文件——pip install geetest——引入其封装的js模块 代码分为三段:生成验证码——显示验证码——验证验证码. from ...
- 【原创】运维基础之Zabbix(1)简介、安装、使用
zabbix 4 官方:https://www.zabbix.com/ 一 简介 Monitor anythingSolutions for any kind of IT infrastructure ...
- 使用Java API操作HDFS文件系统
使用Junit封装HFDS import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.*; import org ...
- Centos6.10源码部署zabbix-3.2.6
环境:Centos6.10 已有lnmp环境 mysql5.7 php7.2 创建zabbix数据库 mysql> create database zabbix character se ...
- 在Pycharm中自动添加时间日期作者等信息
1.按照下面路径以此打开File→→Settings→→Editor→→File and code Templates 右侧找到Python Script,如下图 2.设置相关代码如下 ##!/usr ...