题目传送门

题意:裸的对原点的极角排序,凸包貌似不行。

/************************************************
* Author :Running_Time
* Created Time :2015/11/3 星期二 14:46:47
* File Name :POJ_2007.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos (-1.0);
int dcmp(double x) {
if (fabs (x) < EPS) return 0;
else return x < 0 ? -1 : 1;
}
struct Point {
double x, y;
Point () {}
Point (double x, double y) : x (x), y (y) {}
Point operator - (const Point &r) const { //向量减法
return Point (x - r.x, y - r.y);
}
bool operator == (const Point &r) const { //判断同一个点
return dcmp (x - r.x) == 0 && dcmp (y - r.y) == 0;
}
bool operator < (const Point &r) const {
return x < r.x || (dcmp (x - r.x) == 0 && y < r.y);
}
};
typedef Point Vector;
Point read_point(void) {
double x, y;
scanf ("%lf%lf", &x, &y);
return Point (x, y);
}
double polar_angle(Vector A) {
return atan2 (A.y, A.x);
}
double dot(Vector A, Vector B) {
return A.x * B.x + A.y * B.y;
}
double cross(Vector A, Vector B) {
return A.x * B.y - A.y * B.x;
} bool cmp(Point a, Point b) {
return cross (a - Point (0, 0), b - Point (0, 0)) > 0;
} int main(void) {
vector<Point> ps;
double x, y;
while (scanf ("%lf%lf", &x, &y) == 2) {
ps.push_back (Point (x, y));
}
sort (ps.begin ()+1, ps.end (), cmp);
for (int i=0; i<ps.size (); ++i) {
printf ("(%.0f,%.0f)\n", ps[i].x, ps[i].y);
} //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0;
}

  

简单几何(极角排序) POJ 2007 Scrambled Polygon的更多相关文章

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

    水题,根本不用凸包,就是一简单的极角排序. 叉乘<0,逆时针. #include <iostream> #include <cstdio> #include <cs ...

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

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

  3. POJ 2007 Scrambled Polygon [凸包 极角排序]

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8636   Accepted: 4105 ...

  4. poj 2007 Scrambled Polygon 极角排序

    /** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 retur ...

  5. POJ 2007 Scrambled Polygon 极角序 水

    LINK 题意:给出一个简单多边形,按极角序输出其坐标. 思路:水题.对任意两点求叉积正负判断相对位置,为0则按长度排序 /** @Date : 2017-07-13 16:46:17 * @File ...

  6. ●POJ 2007 Scrambled Polygon

    题链: http://poj.org/problem?id=2007 题解: 计算几何,极角排序 按样例来说,应该就是要把凸包上的i点按 第三像限-第四像限-第一像限-第二像限 的顺序输出. 按 叉积 ...

  7. POJ 2007 Scrambled Polygon 凸包

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7214   Accepted: 3445 ...

  8. poj 2007 Scrambled Polygon(极角排序)

    http://poj.org/problem?id=2007 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6701   A ...

  9. POJ 2007 Scrambled Polygon 凸包点排序逆时针输出

    题意:如题 用Graham,直接就能得到逆时针的凸包,找到原点输出就行了,赤果果的水题- 代码: /* * Author: illuz <iilluzen[at]gmail.com> * ...

随机推荐

  1. thinkphp中I方法

    概述 正如你所见到的一样,I方法是ThinkPHP众多单字母函数中的新成员,其命名来自于英文Input(输入),主要用于更加方便和安全的获取系统输入变量,可以用于任何地方,用法格式如下:I('变量类型 ...

  2. [Effective JavaScript 笔记]第25条:使用bind方法提取具有确定接收者的方法

    js里方法和属性值为函数,就像一个东西两种称呼一个样,比如土豆,也叫马铃薯,一个样.既然一样,那就可以对对象的方法提取出来为函数,然后把提取出来的函数作为回调函数直接传递给高阶函数. 高阶函数是什么 ...

  3. 在CentOS 7 上搭建LAMP

    导读 要求:httpd的动态和静态资源分为两台主机提供,mysql也用单独一台主机.httpd服务提供虚拟主机,一个虚拟主机用于提供phpMyAdmin:另一个虚拟主机用于提供wordpress.安装 ...

  4. 关于windows程序的学习及思考系列之一

    1.窗口类的注册 a.windows程序中最简单的就是创建一个简单的窗口,而窗口程序的创建是基于窗口类的,窗口类决定了处理窗口消息的过程函数. b.一个窗口类可以用于创建多个窗口,也就是说窗口是窗口类 ...

  5. HTML5 manifest离线缓存

    一.基本概念 离线缓存是HTML5新引入的技术,能够让你的Web应用程序指定哪些文件可以缓存在本地,使得你的网络断开时依然可以通过本地的缓存来进行访问浏览. 二.使用方法 1. MIME type 声 ...

  6. 38.输出1到最大的N位数[Print 1 to max number of N bits]

    [题目] 输入数字n,按顺序输出从1最大的n位10进制数.比如输入3,则输出1.2.3一直到最大的3位数即999. [分析] 这是一道很有意思的题目.看起来很简单,其实里面却有不少的玄机. [常规思路 ...

  7. 使用php递归计算目录大小

    统计一个目录大小,因为不知道目录中子目录的深度,所以for循环很难实现,但是用递归调用很容易实现,只要统计出一个目录中所有文件的大小,那么每一次调用就可以了,随便建了个目录,建立一些文件,方法代码如下 ...

  8. canvas API ,通俗的canvas基础知识(二)

    上文我们讲到了画一条线,画矩形,写文字,总算是有了一个好的开头,如果还没有看的同学出门左转,先看看那篇,这里就不多做叙述了,接下来我们看比较复杂的一些属性和方法! 讲之前呢,我还是想温习一下,毕竟上文 ...

  9. javascript输出AscII码扩展集中的字符

    function test(){ var c=""; for(var i=1;i<65536;i++){ if((i%10)==0){ c+=i+':\t'+String.f ...

  10. 提高IO性能

    noatime - 不更新文件系统上 inode 访问记录,可以提升性能 [root@ok etc]# cat /etc/fstab |grep noatime /dev/mapper/vg_ok-l ...