poj2007 Scrambled Polygon【极角排序】
来源:互联网 发布:js防水涂料怎么用 编辑:程序博客网 时间:2024/06/06 02:40
题目链接:http://poj.org/problem?id=2007
题意:好像就是给你个凸包,然后输出极角排序后的结果
解析:极角排个序就好?
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <string>using namespace std;const int maxn = 1e5+100;const double eps = 1e-10;const double pi = acos(-1.0);struct point{ double x,y; point() {} point(double _x,double _y) { x = _x; y = _y; } bool operator < (const point &b) const { if(y==b.y) return x<b.x; return y<b.y; }}a[maxn],ans[maxn];double x_mul(point p0,point p1,point p2){ return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}double dis(point p1,point p2){ return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));}bool cmp(point t1,point t2){ double tmp = x_mul(a[0],t1,t2); if(tmp==0) return dis(a[0],t1)<dis(a[0],t2); else return tmp>0;}void slove(int n){ //sort(a,a+n); sort(a+1,a+n,cmp); for(int i=0;i<n;i++) printf("(%.0f,%.0f)\n",a[i].x,a[i].y);}int main(void){ int n = 0; while(~scanf("%lf %lf",&a[n].x,&a[n].y)) n++; slove(n); return 0;}
0 0
- poj2007 Scrambled Polygon【极角排序】
- poj2007-Scrambled Polygon (极角排序)
- Scrambled Polygon(poj2007极角排序输出凸包)
- poj2007 Scrambled Polygon (叉积极角排序)
- POJ2007 Scrambled Polygon
- POJ2007 Scrambled Polygon
- POJ2007-Scrambled Polygon
- POJ2007--Scrambled Polygon
- POJ2007 Scrambled Polygon
- POJ2007 Scrambled Polygon
- poj2007——Scrambled Polygon
- poj 2007 Scrambled Polygon 极角排序
- POJ 2007 Scrambled Polygon(极角排序)
- POJ 2007 Scrambled Polygon 极角排序
- HDU-2007 Scrambled Polygon 极角排序
- poj 2007 Scrambled Polygon [极角排序]
- POJ 2007 Scrambled Polygon 极角排序
- PKU 2007 Scrambled Polygon 极角排序
- maven远程下载失败,手动导包到本地仓库的正确姿态
- Android6.0之AMS数据结构梳理
- MATLAB FASTER RCNN 崩溃
- Linux下xorg进程CPU占用率过高时的一个解决方案
- java面试①整体流程
- poj2007 Scrambled Polygon【极角排序】
- Android性能优化之UncaughtExceptionHandler定制自己的错误日志系统
- 面试感悟----一名3年工作经验的程序员应该具备的技能
- 数组中使用strcpy、memcpy复制字符串,末尾添加‘\0’
- Python异步通信模块asynchat
- maven+eclipse+SSM框架
- 集合相等问题
- SQL Server中建立外键的方法
- DotNet:Socket Server 异步套接字服务端实现