博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj1106
阅读量:6973 次
发布时间:2019-06-27

本文共 1107 字,大约阅读时间需要 3 分钟。

极坐标排序+叉积判断夹角

View Code
#include 
#include
#include
#include
#include
#include
using namespace std;#define maxn 200#define eps 1.0e-8struct Point{ int x, y;}s, point[maxn];double r;int n;bool operator < (const Point &a, const Point &b){ return atan2((double)a.x, (double)a.y) < atan2((double)b.x, (double)b.y);}void input(){ int cnt = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d%d", &point[cnt].x, &point[cnt].y); point[cnt].x -= s.x; point[cnt].y -= s.y; if (r * r > point[cnt].x * point[cnt].x + point[cnt].y * point[cnt].y - eps) cnt++; } n = cnt;}double xmulti(Point a, Point b){ return a.x * b.y - a.y * b.x;}bool within(Point a, Point b){ return xmulti(b, a) > -eps;}int work(){ int r = 0; int ans = 0; for (int i = 0; i < n; i++) { while (r - i < n && within(point[i], point[r % n])) r++; ans = max(ans, r - i); } return ans;}int main(){ //freopen("t.txt", "r", stdin); while (scanf("%d%d%lf", &s.x, &s.y, &r), r >= 0) { input(); sort(point, point + n); printf("%d\n", work()); } return 0;}

 

转载地址:http://ekesl.baihongyu.com/

你可能感兴趣的文章
《Adobe After Effects CS4经典教程》——1.5 对合成图像作动画处理
查看>>
Centos7.x系统网卡启动报错问题排查
查看>>
ROCBOSS v2.1.0 正式发布,PHP 微社区
查看>>
《微信公众平台开发:从零基础到ThinkPHP5高性能框架实践》——1.3 微信公众平台的使用...
查看>>
PostGIS 坐标转换(SRID)的边界问题 - ST_Transform
查看>>
苹果Mac 30周年:那些改变世界的人和Mac电脑
查看>>
倪光南:建议政府停止采购和使用“ Win10 政府版”
查看>>
Arquillian OSGi 2.2.1.Final 发布
查看>>
《深入理解ElasticSearch》——第2章查询DSL进阶 2.1 Apache Lucene默认评分公式解释...
查看>>
《Adobe Premiere Pro CS4经典教程》——1.3 Adobe Premiere Pro CS4中的非线性编辑
查看>>
《VoIP技术构架(第2版·修订版)》一 第2章 企业电话的今天
查看>>
浏览器自动化测试解決方案 Geb
查看>>
《C程序员从校园到职场》一导读
查看>>
我希望一年前就知道 MongoDB 的那些事儿
查看>>
《Spark 官方文档》Spark独立模式
查看>>
《树莓派Python编程入门与实战(第2版)》——1.5 决定如何购买外围设备
查看>>
完全指南之在 Ubuntu 操作系统中安装及卸载软件
查看>>
《Spark 官方文档》在YARN上运行Spark
查看>>
《C++面向对象高效编程(第2版)》——2.5 数据封装的优点
查看>>
判断email格式的正则表达式
查看>>