Scrambled Polygon--poj2007(极角排序模板)
http://poj.org/problem?id=2007
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<vector>
using namespace std;
#define INF 0xfffffff
#define ESP 1e-8
#define memset(a,b) memset(a,b,sizeof(a))
#define N 2100 struct Point
{
double x,y;
int index;
Point(double x=,double y=):x(x),y(y) {}
Point operator - (const Point &temp)const
{
return Point(x-temp.x,y-temp.y);
}
Point operator + (const Point &temp)const
{
return Point(x+temp.x,y+temp.y);
}
int operator ^(const Point &temp)const ///求叉积
{
double t=(x*temp.y)-(y*temp.x);
if(t>ESP)
return ;
if(fabs(t)<ESP)
return ;
return -;
}
double operator * (const Point &temp)const
{
return x*temp.x+y*temp.y;
}
bool operator == (const Point &temp)const
{
return (x==temp.x)&&(y==temp.y);
}
} p[N]; double dist(Point a1,Point a2)
{
return sqrt((a1-a2)*(a1-a2));
}
int pos=; int cmp(Point a1,Point a2)
{
int t=(a1-p[pos])^(a2-p[pos]);
if(t<) return false;
else
return true;
} int main()
{
int n;
n=;
while(scanf("%lf %lf",&p[n].x,&p[n].y)!=EOF) n++;
pos=; for(int i=; i<n; i++)
{
sort(p+i,p+n,cmp);
pos++;
}
for(int i=; i<n; i++)
printf("(%.0lf,%.0lf)\n",p[i].x,p[i].y);
printf("\n");
return ;
}
Scrambled Polygon--poj2007(极角排序模板)的更多相关文章
- POJ 2007 Scrambled Polygon [凸包 极角排序]
Scrambled Polygon Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8636 Accepted: 4105 ...
- poj 2007 Scrambled Polygon(极角排序)
http://poj.org/problem?id=2007 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6701 A ...
- poj2007极角排序
裸的极角排序,但是要把0,0放在第一个(话说这题题目真是巨长,废话也多...) #include<map> #include<set> #include<cmath> ...
- POJ 2007 Scrambled Polygon 凸包点排序逆时针输出
题意:如题 用Graham,直接就能得到逆时针的凸包,找到原点输出就行了,赤果果的水题- 代码: /* * Author: illuz <iilluzen[at]gmail.com> * ...
- 简单几何(极角排序) POJ 2007 Scrambled Polygon
题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...
- POJ 2007 Scrambled Polygon (简单极角排序)
题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio. ...
- poj 2007 Scrambled Polygon 极角排序
/** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 retur ...
- POJ 2007 Scrambled Polygon(简单极角排序)
水题,根本不用凸包,就是一简单的极角排序. 叉乘<0,逆时针. #include <iostream> #include <cstdio> #include <cs ...
- Scrambled Polygon POJ - 2007 极角排序
题意: 给你n个点,这n个点可以构成一个多边形(但是不是按顺序给你的).原点(0,0)为起点,让你按顺序逆序输出所有点 题解: 就是凸包问题的极角排序 用double一直Wa,改了int就可以了 // ...
随机推荐
- 更新centos系统的python版本
因今天安装一程序需要用到python高版本,所以升级来系统自带的python. 先查询下系统的python版本是多少. #python -V 显示出来的是2.4.3,太老了,现在升级到比较稳定的版本3 ...
- 关于bin和obj文件夹。debug 和release的区别(转)
关于bin和obj文件夹. 楼主hcaihao(影子男孩)2002-05-29 20:04:24 在 .NET技术 / C# 提问 VS.Net会生成bin和obj文件夹以及它们下面的Debug和Re ...
- 51nod 1432 独木舟
基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 n个人,已知每个人体重.独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人.显然要求总重量不超过独木舟承 ...
- ABAP的HTTP_GET和Linux的curl
curl是利用URL语法在命令行方式下工作的开源文件传输工具,广泛应用在Unix,多种Linux发行版中. 在Windows系统下也有移植版. curl尤其被广泛应用在github上众多开源软件和框架 ...
- 原创:mysql下载 实战 最强最全的无脑白痴版 给小白的爱
- 原创Couldn't read packet: Connection reset by peer 错误排查思路(推荐)
作为一个运维 不是你懂多少知识才是你的价值 你有幸能遇到多少错误才是你的最大的价值 知识 你有我有大家有 错误我有你没有 这便是我的价值 我遇到一个错误 蛮难遇到的一个错误 所以想分享给大家 下面我 ...
- Gear Pump: Why Install A Pressure Reducing Valve?
When the Gear Pump Manufacturers prompts to install a gear pump, the following points should ...
- 如何给run()方法传参数
实现的方式主要有三种 1.构造函数传参 2.成员变量传参 3.回调函数传参 问题:如何实现处理线程的返回值? 1.主线程等待法(优点:实现起来简单,缺点:需要等待的变量一多的话,代码就变的非常臃肿.而 ...
- 手把手入门docker (好多图)
1.什么是docker? ---->我的理解是将许多应用一起打包成一个镜像,拿这个镜像去其他服务器上运行起来就可以.不需要单个单个去配置啦. 2.怎样在window下的安装. ---->刚 ...
- Elasticsearch document深度剖析
1. 针对Elasticsearch并发冲突问题,ES内部是如何解决的? 1)ES内部是线程异步并发修改的,是基于_version版本号进行乐观锁并发控制的: 2)若后修改的先到了,那么修改后版本发生 ...