POJ 1981 Circle and Points 计算几何
来源:互联网 发布:linux创建目录 ls 编辑:程序博客网 时间:2024/05/01 17:46
题目大意
给出平面上的一些点,求一个单位圆最多能够覆盖多少点。
思路
数据范围300,但是没有用,多组数据就是要卡
做法就是枚举每个点,做一个一这个点为圆心的单位圆。之后将所有在这个圆里的点弄出来,以这些点为圆心做单位圆,与开始的单位圆会产生一段圆弧,最后求哪一段圆弧被覆盖的次数最多就是答案。
CODE
#define _CRT_SECURE_NO_WARNINGS#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define MAX 510#define EPS 1e-7using namespace std;struct Point{ double x, y; Point(const double &_, const double &__):x(_), y(__) {} Point() {} Point operator +(const Point &a)const { return Point(x + a.x, y + a.y); } Point operator -(const Point &a)const { return Point(x - a.x, y - a.y); } Point operator *(const double &a)const { return Point(x * a, y * a); } Point operator /(const double &a)const { return Point(x / a, y / a); } void Read() { scanf("%lf%lf", &x, &y); }}point[MAX];inline double Calc(const Point &p1, const Point &p2){ return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));}inline Point Change(const Point &v){ return Point(-v.y, v.x);}int points;bool v[MAX];int stack[MAX], top;inline int GetAns(const Point &p1, const Point &p2){ double dis = Calc(p1, p2) / 2; if(dis > 1.0) return 0; Point o = Point((p1.x + p2.x) / 2, (p1.y + p2.y) / 2) + (Change(p1 - p2) / (dis * 2)) * sqrt(1 - dis * dis); int re = 0; for(int i = 1; i <= top; ++i) re += Calc(point[stack[i]], o) <= 1.0 + EPS; return re + 1;}int main(){ while(scanf("%d", &points), points) { for(int i = 1; i <= points; ++i) point[i].Read(); int ans = 1; for(int i = 1; i <= points; ++i) { top = 0; for(int j = 1; j <= points; ++j) if(i != j && Calc(point[i], point[j]) < 2.0) stack[++top] = j; for(int j = 1; j <= top; ++j) ans = max(ans, GetAns(point[i], point[stack[j]])); } printf("%d\n", ans); } return 0;}
0 0
- 【计算几何】 POJ 1981 Circle and Points
- POJ 1981 Circle and Points 计算几何
- JOJ 2109 && POJ 1981 Circle and Points 计算几何 单位圆覆盖问题
- POJ1981 Circle and Points(计算几何)
- poj1981 Circle and Points 计算几何
- POJ 1981 Circle and Points
- zoj 2167 || poj 1981 Circle and Points
- POJ 1981 Circle and Points 已翻译
- poj 1981 Circle and Points (模板)
- poj 1981 Circle and Points poj 2693 Chocolate Chip Cookies
- POJ 2986 A Triangle and a Circle(计算几何)
- POJ 2986 A Triangle and a Circle(计算几何)
- poj 1981 Circle and Points(圆覆盖点问题)
- [极大化 极角排序] POJ 1981 Circle and Points & BZOJ 1338 Pku1981 Circle and Points单位圆覆盖
- (计算几何8.1.2.3)POJ 1329 Circle Through Three Points(利用叉积来计算三角形的外接圆的圆心)
- 计算几何-hdoj-1221-Rectangle and Circle
- poj 3512 Incidental Points 计算几何
- poj 3512 Incidental Points(计算几何)
- iis 配置.net网站
- android WebView(二)缩放
- Web.xml 中的listener、 filter、servlet 加载顺序及其详解
- 搭建本地GIT仓库和工作空间
- PHP Eclipse从html页面跳转PHP页面问题
- POJ 1981 Circle and Points 计算几何
- TFS2010安装教程
- HDU 3999 BST基础
- Oracle中job的使用详解
- jQuery源码解析--插件接口设计($.extend)
- oracle 简单备份
- Android常用UI之Spinner
- 《Thinking in Java》读书笔记之并发(一)
- 投影矩阵与最小二乘