Scrambled Polygon - POJ 2007(求凸包)
给一些点,这些点都是一个凸包上的顶点,以第一个点为起点顺时针把别的点拍排一下序列。
分析:最简单的极坐标排序了.....................
代码如下:
--------------------------------------------------------------------------------------------------------------------------
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<queue>
#include<string>
#include<vector>
#include<math.h>
using namespace std; const double EPS = 1e-;
const double PI = acos(-);
const int MAXN = 1e3+;
int sta[MAXN], top;
int Sign(double t)
{
if(t > EPS)return ;
if(fabs(t) < EPS)return ;
return -;
}
struct point
{
double x, y;
point(double x=, double y=):x(x), y(y){}
point operator - (const point &t)const{
return point(x-t.x, y-t.y);
}
double operator ^(const point &t)const{
return x*t.y - y*t.x;
}
double operator *(const point &t)const{
return x*t.x + y*t.y;
}
}p[MAXN];
double Dist(point a, point b)
{
return sqrt((a-b)*(a-b));
}
bool cmp(point a, point b)
{
int t = Sign((a-p[])^(b-p[])); if(t == )
return Dist(a, p[]) < Dist(b, p[]);
return t > ;
} int main()
{
int i=, N; while(scanf("%lf%lf", &p[i].x, &p[i].y) != EOF)
i++; N = i;
sort(p+, p+N, cmp); for(i=; i<N; i++)
printf("(%.0f,%.0f)\n", p[i].x, p[i].y); return ;
}
Scrambled Polygon - POJ 2007(求凸包)的更多相关文章
- Scrambled Polygon POJ - 2007 极角排序
题意: 给你n个点,这n个点可以构成一个多边形(但是不是按顺序给你的).原点(0,0)为起点,让你按顺序逆序输出所有点 题解: 就是凸包问题的极角排序 用double一直Wa,改了int就可以了 // ...
- poj 3525 求凸包的最大内切圆
Most Distant Point from the Sea Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3640 ...
- POJ 2187 求凸包上最长距离
简单的旋转卡壳题目 以每一条边作为基础,找到那个最远的对踵点,计算所有对踵点的点对距离 这里求的是距离的平方,所有过程都是int即可 #include <iostream> #includ ...
- POJ 2007 Scrambled Polygon 凸包
Scrambled Polygon Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7214 Accepted: 3445 ...
- POJ 2007 Scrambled Polygon [凸包 极角排序]
Scrambled Polygon Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8636 Accepted: 4105 ...
- POJ 2007 Scrambled Polygon 极角序 水
LINK 题意:给出一个简单多边形,按极角序输出其坐标. 思路:水题.对任意两点求叉积正负判断相对位置,为0则按长度排序 /** @Date : 2017-07-13 16:46:17 * @File ...
- POJ 2187 Beauty Contest【旋转卡壳求凸包直径】
链接: http://poj.org/problem?id=2187 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...
- 计算几何--求凸包模板--Graham算法--poj 1113
Wall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28157 Accepted: 9401 Description ...
- poj 1113:Wall(计算几何,求凸包周长)
Wall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28462 Accepted: 9498 Description ...
随机推荐
- java中事件处理探究
事件的触发可以源于用户,也可以用代码来主动设置事件的发生.如setSelected()java.awt.event中 听众接口 事件类 适配器类 ComponentListener Conta ...
- 配置MyEclipse+Hibernate连接Sql Server 2008出错
下文主要是讲述最近配置MyEclipse连接Sql Server 2008时遇到的一个问题,而不关注如何配置Sql Server 2008支持TCP/IP连接.Hibernate如何操作Sql Ser ...
- js实现简单计算器
效果图: 刚开始做时没考虑到清零和退格两个功能,嘻嘻,后来加的整体与传统计算器比有点小瑕疵. 代码: <!DOCTYPE html><html><head> < ...
- boost::bind实践
第一部分源码为基础实践: /*Beyond the C++ Standard Library ( An Introduction to Boost )[CN].chm*/ /*bind的用法*/ #i ...
- npm 好用工具 for 前端
1. caniuse npm install -g caniuse-cmd
- 探讨 yum 与 rpm 的安装包数量
安装包数量不相等 [root@localhost ~]# rpm -qa | wc –l #列出所有被安装的rpm package 422 [root@localhost ~]# yum list i ...
- Dictionary通过Value找到它的key
private void GetDicKeyByValue() { Dictionary<string, string> dic = new Dictionary<string, s ...
- 2016021904 - 如何使用Memory Analyzer
如何使用Memory Analyzer呢? 0.有内存溢出的代码code.<深入理解java虚拟机>中代码 package neutron.oom.heap; import java.ut ...
- LeetCode(3) || Median of Two Sorted Arrays
LeetCode(3) || Median of Two Sorted Arrays 题记 之前做了3题,感觉难度一般,没想到突然来了这道比较难的,星期六花了一天的时间才做完,可见以前基础太差了. 题 ...
- 如何通过数据库修改WordPress后台登录密码
大家是否有过因为忘记WordPress后台登陆密码的时候?其实WordPress后台登陆密码的找回或修改的方法有多种,比如通过邮箱重启密码,又或者通过主机控制面板进入数据库修改等等.本篇教程以GoDd ...