poj2007极角排序
裸的极角排序,但是要把0,0放在第一个(话说这题题目真是巨长,废话也多。。。)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; struct point{
double x,y;
}p[N];
double dis(point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
double dir(point p1,point p2,point p3)
{
return (p3.x-p1.x)*(p2.y-p1.y)-(p3.y-p1.y)*(p2.x-p1.x);
}
bool comp(point p1,point p2)
{
double te=dir(p[],p1,p2);
if(te<)return ;
if(te==&&dis(p[],p1)<dis(p[],p2))return ;
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int cnt=;
while(cin>>p[cnt].x>>p[cnt].y){
//if(p[cnt].x==-1&&p[cnt].y==-1)break;
cnt++;
}
int pos;
for(int i=;i<cnt;i++)
if(p[i].x==&&p[i].y==)
pos=i;
swap(p[],p[pos]);
sort(p+,p+cnt,comp);
for(int i=;i<cnt;i++)
cout<<"("<<p[i].x<<","<<p[i].y<<")"<<endl;
return ;
}
poj2007极角排序的更多相关文章
- poj2007(极角排序)
利用叉积按照逆时针方向进行极角排序, #define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<algorithm&g ...
- POJ 1696 Space Ant 【极角排序】
题意:平面上有n个点,一只蚂蚁从最左下角的点出发,只能往逆时针方向走,走过的路线不能交叉,问最多能经过多少个点. 思路:每次都尽量往最外边走,每选取一个点后对剩余的点进行极角排序.(n个点必定能走完, ...
- Space Ant---poj1696(极角排序)
题目链接:http://poj.org/problem?id=1696 题意:给你n个点,然后我们用一条线把它们连起来,形成螺旋状: 首先找到左下方的一个点作为起点,然后以它为原点进行极角排序,找到极 ...
- poj2280Amphiphilic Carbon Molecules(极角排序)
链接 卡了几天的破题,对于hdu的那份数据,这就一神题.. 借助极角排序,枚举以每一个点进行极角排序,然后构造两条扫描线,一个上面一个下面,两条同时走,把上线和下线的点以及上线左边的点分别统计出来,如 ...
- LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)
1285 - Drawing Simple Polygon PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...
- 简单几何(极角排序) POJ 2007 Scrambled Polygon
题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...
- poj 1696 Space Ant (极角排序)
链接:http://poj.org/problem?id=1696 Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- POJ 2007 Scrambled Polygon (简单极角排序)
题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio. ...
- POJ 1696 Space Ant(极角排序)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2489 Accepted: 1567 Descrip ...
随机推荐
- jQuery动态效果学习笔记
资料来源 W3Cschool 1.元素的显示与隐藏 1.1显示元素show() 语法 $(selector).show(speed,callback); 显示已经设置隐藏的元素 1.2隐藏元素hide ...
- 使用Spring Session和Redis解决分布式Session跨域共享问题
http://blog.csdn.net/xlgen157387/article/details/57406162 使用Spring Session和Redis解决分布式Session跨域共享问题
- iOS开发之XMPPFramework开发基础介绍
1 使用iPhoneXMPP实例 2 修改xmppstream设置 3 基础协议的介绍 协议 协议简介 XEP-0009 在两个XMPP实体间传输XML-RPC编码请求和响应 XEP-0006 使能与 ...
- windows库
1.windows库的存在方式 1.1.静态库:不能被加载的程序,可以理解为目标程序的归档:*.lib. 1.2.动态库:是可以被加载的程序:*.dll. 2.静态库 2.1.静态库的特点 目标 ...
- [Linux 001]——计算机和操作系统的基础知识
在正式开始学习 Linux 操作系统之前,有必要先回顾/学习一下计算机和操作系统的基本知识,为我们在后续的学习中铺路搭桥,在了解计算机一些基础原理的条件下再去进行学习,理解应该会更透彻一些.我会从一个 ...
- # 20145103《Java程序设计》第6周学习总结
20145103<Java程序设计>第6周学习总结 教材学习内容总结 第十章 第十章输入和输出 10.1.1 ·若要将数据从来源中取出,可以使用输入串流:若要将数据写入目的地,可以使用输出 ...
- C++之STL迭代器(iterator)
[摘要]本文是对STL--迭代器(iterator)的讲解,对学习C++编程技术有所帮助,与大家分享. 原文:http://www.cnblogs.com/qunews/p/3761405.html ...
- 1_archlinux_安装篇
系统安装 可参考网友的文章: https://www.douban.com/note/263375303/?type=like http://www.68idc.cn/help/server/linu ...
- 学习记录:交叉编译环境配置(buildroot and gdb&gdbserver)【转】
本文转载自:https://blog.csdn.net/zhy025907/article/details/52332528 1,背景 因为参加公司的路由器逆向培训,首先需要的就是环境的配置准备工作, ...
- Java 面试题代码类收集
long temp=(int)3.9; System.out.println(temp); temp%=2; System.out.println(temp); 3 1 Java里面类的方法名可以与类 ...