裸的极角排序,但是要把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极角排序的更多相关文章

  1. poj2007(极角排序)

    利用叉积按照逆时针方向进行极角排序, #define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<algorithm&g ...

  2. POJ 1696 Space Ant 【极角排序】

    题意:平面上有n个点,一只蚂蚁从最左下角的点出发,只能往逆时针方向走,走过的路线不能交叉,问最多能经过多少个点. 思路:每次都尽量往最外边走,每选取一个点后对剩余的点进行极角排序.(n个点必定能走完, ...

  3. Space Ant---poj1696(极角排序)

    题目链接:http://poj.org/problem?id=1696 题意:给你n个点,然后我们用一条线把它们连起来,形成螺旋状: 首先找到左下方的一个点作为起点,然后以它为原点进行极角排序,找到极 ...

  4. poj2280Amphiphilic Carbon Molecules(极角排序)

    链接 卡了几天的破题,对于hdu的那份数据,这就一神题.. 借助极角排序,枚举以每一个点进行极角排序,然后构造两条扫描线,一个上面一个下面,两条同时走,把上线和下线的点以及上线左边的点分别统计出来,如 ...

  5. LightOJ 1285 - Drawing Simple Polygon (几何,极角排序)

    1285 - Drawing Simple Polygon   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: ...

  6. 简单几何(极角排序) POJ 2007 Scrambled Polygon

    题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...

  7. poj 1696 Space Ant (极角排序)

    链接:http://poj.org/problem?id=1696 Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  8. POJ 2007 Scrambled Polygon (简单极角排序)

    题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio. ...

  9. POJ 1696 Space Ant(极角排序)

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2489   Accepted: 1567 Descrip ...

随机推荐

  1. PAT 1033 To Fill or Not to Fill[dp]

    1033 To Fill or Not to Fill(25 分) With highways available, driving a car from Hangzhou to any other ...

  2. css3 利用dispaly:flex

    直接上代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...

  3. linux rm指定的文件

    如何删除一个目录下的除了想要的文件之外的所有文件 rm `ls | grep -v "aa"` Linux下 报错“命令参数列表过长”,在用mv命令一次移动3万多个文件时失败了,原 ...

  4. testng日志 ITestListener

    上一节我们写一个日志类 extends   TestListenerAdapter ----------TestListenerAdapter 是 ITestListener 实现的一个类 这一节,我 ...

  5. FMX 高手博客

    http://www.cnblogs.com/weii 苹果系统,很详细http://blog.sina.com.cn/s/articlelist_1157240623_0_1.html 红鱼,资料很 ...

  6. C# 使用 Windows API 发送文件到打印机

    最近需要做一个打印的功能,于是在网上找到了这么一个方法. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public cl ...

  7. 002-启动spring boot应用

    一.idea启动. 1.在src目录里面找到启动类(包含主函数的类)DemoApplication,然后在该类里面右键,选择run DemoApplication.main,即spring boot应 ...

  8. HDU 5963 朋友(树+博弈)

    #include<vector> #include<cstdio> #include<cstring> #include<algorithm> #def ...

  9. MySQL 温故知心(二) 事务的隔离级别

    事务的隔离级别 A事务做了操作 没有提交 对B事务来说 就等于没做 获取的都是之前的数据但是 在A事务中查询的话 查到的都是操作之后的数据没有提交的数据只有自己看得到,并没有update到数据库 查看 ...

  10. UVALive - 4671 K-neighbor substrings (FFT+哈希)

    题意:海明距离的定义:两个相同长度的字符串中不同的字符数.现给出母串A和模式串B,求A中有多少与B海明距离<=k的不同子串 分析:将字符a视作1,b视作0.则A与B中都是a的位置乘积是1.现将B ...