博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
简单几何(极角排序) POJ 2007 Scrambled Polygon
阅读量:7105 次
发布时间:2019-06-28

本文共 1771 字,大约阅读时间需要 5 分钟。

 

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

 

/************************************************* Author        :Running_Time* Created Time  :2015/11/3 星期二 14:46:47* File Name     :POJ_2007.cpp ************************************************/#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;#define lson l, mid, rt << 1#define rson mid + 1, r, rt << 1 | 1typedef 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
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

  

转载于:https://www.cnblogs.com/Running-Time/p/4935443.html

你可能感兴趣的文章
学习JDK1.8集合源码之--HashSet
查看>>
【九度OJ】题目1204:农夫、羊、菜和狼的故事 -----------状态压缩+搜索
查看>>
【转】ubuntu sudo update与upgrade的作用及区别
查看>>
JMS基本概念
查看>>
XHTML和HTML有什么区别
查看>>
Java的四种引用
查看>>
java.util.ConcurrentModificationException --map
查看>>
synchronized 专题
查看>>
Swing中耗时任务需要另起新线程,这个新线程中更新GUI的操作仍需由EDT来做(转)...
查看>>
多听多想少说(转)
查看>>
m2eclipse简单使用,创建Maven项目 ,运行mvn命令(转)
查看>>
C# WebBrowser设置代理
查看>>
位运算的用途
查看>>
C语言与水仙花数
查看>>
(64位)本体学习程序(ontoEnrich)系统配置说明文档
查看>>
谈谈Java的匿名内部类
查看>>
一些位运算的技巧整理
查看>>
关于数据验证
查看>>
类似于资料修改并且保存的操作
查看>>
17.在一个字符串中找到第一个只出现一次的字符。如输入abaccdeff,则输出b
查看>>