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 ...
随机推荐
- [物理学与PDEs]第1章习题10 自由电磁场在 Lorentz 规范变换下可使标势为零
在自由电磁场的情况, 证明: 在保持 Lorentz 条件下的规范变换下, 可使标势恒为零. 证明: 取 $\psi$ 满足 $\cfrac{\p \psi}{\p t}=\phi$ 且 $\cfra ...
- sessionStorage:写入记事本功能[内容写入sessionStorage中,读取,删除]
知识点: 1.设置sessionStorage----setItem:sessionStorage.setItem(key,data); 存储数据使用key是唯一,不可重复,每触发都生成:如用一个固定 ...
- 【webpack】中file-loader和url-loader使用方法
file-loader 可以指定要复制和放置资源文件的位置,以及如何使用版本哈希命名以获得更好的缓存.此外,这意味着 你可以就近管理图片文件,可以使用相对路径而不用担心部署时 URL 的问题.使用正确 ...
- L1-Day3
L1-Day31.太阳从西边落下. [我的翻译]The sun falls in the west. [标准答案]The sun sets in the west. [对比分析]落下fall与set的 ...
- django drf 基础学习5
一 简介: 用户登录的验证 二 验证机制: 1 session session需要在服务端存储能够通过session_id而获取的信息,每次请求到达服务端时,需要根据session_id这个ke ...
- warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
在C++中, char* p = "abc"; // valid in C, invalid in C++ 会跳出警告:warning: ISO C++ forbids conve ...
- django的一些常用指令
生成Django项目 django-admin startproject mysite 启动服务 python manage.py runserver 本地化中间件 'django.mididdlew ...
- aiohttp使用队列
获取百度的搜索结果,然后把百度的长链接,获取到真实的url import time import aiofiles import aiohttp import asyncio from lxml im ...
- [51nod1965]奇怪的式子
noteskey 怎么说,魔性的题目...拿来练手 min_25 正好...吧 首先就是把式子拆开来算贡献嘛 \[ANS=\prod_{i=1}^n \sigma_0(i)^{\mu(i)} \pro ...
- 【转】Java中文乱码的解决
在基于Java的编程中,经常会碰到汉字的处里及显示的问题,比如一大堆乱码或问号. 这是因为JAVA中默认的编码方式是UNICODE,而中国人通常使用的文件和DB都是基于GB2312或者BIG5等编码, ...