【凸包 Graham法 极角排序】poj 2007 Scrambled Polygon
来源:互联网 发布:java执行sql语句 编辑:程序博客网 时间:2024/06/05 19:32
Link:http://poj.org/problem?id=2007
Graham法求凸包(O(Nlog2N))
/* 极角排序 */#include <cstdio>#include <cmath>#include <algorithm>using namespace std;const int N = 100;const double eps = 1e-6;struct Point{ double x,y;};Point a[N];//是否严格左转,共线不算(叉乘)double xmult(Point a,Point b,Point c) //(ca)×(cb){ return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y);}// sort排序函数bool cmp(const Point &a, const Point &b)//逆时针排序{ Point origin; // 设置原点 origin.x = origin.y = 0; return xmult(origin,b,a)<eps;}int main(){ int n=0; while(scanf("%lf%lf",&a[n].x,&a[n].y)!=EOF) ++n; // 极角排序,第一个空过去 sort(a+1,a+n,cmp); for(int i=0; i<n; ++i) printf("(%.0lf,%.0lf)\n",a[i].x,a[i].y); return 0;}
阅读全文
0 0
- 【凸包 Graham法 极角排序】poj 2007 Scrambled Polygon
- poj 2007 Scrambled Polygon 极角排序
- POJ 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon 极角排序
- poj 2007 Scrambled Polygon [极角排序]
- POJ 2007 Scrambled Polygon 极角排序
- poj 2007 Scrambled Polygon 【极角排序】
- POJ 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon (极角排序)
- 计算几何:极角排序(poj 2007 Scrambled Polygon)与简单凸包(poj 1113 Wall)
- poj 2007 Scrambled Polygon(凸包Graham扫描线模板)
- poj Scrambled Polygon 2007 (凸包基础点排序)
- POJ 2007 Scrambled Polygon(凸包)
- POJ 2007 Scrambled Polygon(凸包)
- POJ 2007 Scrambled Polygon(凸包)
- Scrambled Polygon(poj2007极角排序输出凸包)
- poj 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon(点的极角排序)
- GAWK 学习:AWK 语言基础
- 使用回调函数实现一个简单的计算器;
- Java8中内置的四大核心函数式接口
- [挖坑][uoj]多项式乘法 FFT
- JZOJ2017.08.05 C组
- 【凸包 Graham法 极角排序】poj 2007 Scrambled Polygon
- 1.在win10中搭建Java环境
- 练习 2-6 编写一个函数 setbits(x, p, n, y),该函数返回对x执行下列操作后的结果值:将x中从第p位开始的n个(二进制)位设置为y中最右边n位的值,x的其余各位保持不变。
- PHP基础教程-12 课后作业02
- Maximum GCD 读入
- 关于listview或者recyclerview里面的edittext数据保存问题
- windows安装gensim
- logstash(一):搭建syslog测试环境
- 机器学习笔记——广义线性模型(Generalized Linear Models, GLM)