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 ...
 
随机推荐
- jQuery AJAX load() 方法
			
jQuery load() 方法 jQuery load() 方法是简单但强大的 AJAX 方法. load() 方法从服务器加载数据,并把返回的数据放入被选元素中. 语法: $(selector). ...
 - 网页icon和文本对齐神技 2016.03.23
			
一直以来icon和文本需要对齐都使用vertical-align: middle;的方法,但兼容性不理想.参考了鑫旭大大的博客,终于收获不用vertical-align可以对齐的神技,原博点这里. 代 ...
 - 线性回顾-generalize issue
			
Ein的平均,Eout的平均 用这个平均来justify linear regresssion能够用的很好 noise level 资料里有多少的杂讯 等一下要证明的事情 predictions + ...
 - 滑动开关效果   css3滑动开关】纯CSS3代码实现滑动开关效果-css3滑动效果-css3左右滑动
			
今天看到一篇有关 css3事件的博文,一时兴起便整理下相关的资料. 点击按钮,可以实现开关的滑动效果. 今天看到一篇有关 css3事件的博文,一时兴起便整理下相关的资料. 点击按钮,可以实现开关的滑动 ...
 - 安装ImageMagick扩展出现configure: error: not found. Please provide a path to MagickWand-config or Wand- config program
			
安装ImageMagick扩展报错: checking ImageMagick MagickWand API configuration program... checking Testing /u ...
 - Android内的生命周期整理
			
1. Android App的生命周期: 2. Application的生命周期: 3. Activity的生命周期: 3.1 Fragment的生命周期: 4. Service的生命周期:5. Br ...
 - 从一个模板函数聊聊模板函数里面如何获得T的名字
			
写了个小程序,遇到点问题.总结总结,学习学习 #include<vector> #include<iostream> #include<typeinfo> usin ...
 - servlet跳转jsp
			
ackage com.monkey.servlet; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; im ...
 - EFBaseDal新增删除方法
			
public T Delete(int id ) { var entity = db.Set<T>().Find(id); T t ...
 - tcpdump  本机回环,应该用tcpdump -i lo
			
tcpdump 本机回环,应该用tcpdump -i lo