Scrambled Polygon(凸多边形,斜率)
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 7805 | Accepted: 3712 |
Description
A closed polygon is called convex if the line segment joining any two points of the polygon lies in the polygon. Figure 1 shows a closed polygon which is convex and one which is not convex. (Informally, a closed polygon is convex if its border doesn't have any "dents".) 
The subject of this problem is a closed convex polygon in the coordinate plane, one of whose vertices is the origin (x = 0, y = 0). Figure 2 shows an example. Such a polygon will have two properties significant for this problem.
The first property is that the vertices of the polygon will be confined to three or fewer of the four quadrants of the coordinate plane. In the example shown in Figure 2, none of the vertices are in the second quadrant (where x < 0, y > 0).
To describe the second property, suppose you "take a trip" around the polygon: start at (0, 0), visit all other vertices exactly once, and arrive at (0, 0). As you visit each vertex (other than (0, 0)), draw the diagonal that connects the current vertex with (0, 0), and calculate the slope of this diagonal. Then, within each quadrant, the slopes of these diagonals will form a decreasing or increasing sequence of numbers, i.e., they will be sorted. Figure 3 illustrates this point.

Input
Output
Sample Input
0 0
70 -50
60 30
-30 -50
80 20
50 -60
90 -20
-30 -40
-10 -60
90 10
Sample Output
(0,0)
(-30,-40)
(-30,-50)
(-10,-60)
(50,-60)
(70,-50)
(90,-20)
(90,10)
(80,20)
(60,30)
题意:就是给你一些点,起点已经告诉你是(0,0),让输出这个多边形,斜率从小到大表示;
题解:排下序就好了,注意把除变成乘。。。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x);
struct Node{
int x,y;
friend bool operator < (Node a,Node b){
if(a.y*b.x<b.y*a.x)return true;
else return false;
}
}dt[100010];
int main(){
int k=0;
while(~scanf("%d%d",&dt[k].x,&dt[k].y))k++;
sort(dt+1,dt+k);
for(int i=0;i<k;i++)printf("(%d,%d)\n",dt[i].x,dt[i].y);
return 0;
}
Scrambled Polygon(凸多边形,斜率)的更多相关文章
- Scrambled Polygon(斜率排序)
Scrambled Polygon Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7799 Accepted: 3707 ...
- POJ 2007 Scrambled Polygon 凸包
Scrambled Polygon Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7214 Accepted: 3445 ...
- POJ 2007 Scrambled Polygon [凸包 极角排序]
Scrambled Polygon Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8636 Accepted: 4105 ...
- [LeetCode] Convex Polygon 凸多边形
Given a list of points that form a polygon when joined sequentially, find if this polygon is convex ...
- poj 2007 Scrambled Polygon(极角排序)
http://poj.org/problem?id=2007 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6701 A ...
- 简单几何(极角排序) POJ 2007 Scrambled Polygon
题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...
- POJ 2007 Scrambled Polygon (简单极角排序)
题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio. ...
- Scrambled Polygon - POJ 2007(求凸包)
给一些点,这些点都是一个凸包上的顶点,以第一个点为起点顺时针把别的点拍排一下序列. 分析:最简单的极坐标排序了..................... 代码如下: ----------------- ...
- poj 2007 Scrambled Polygon 极角排序
/** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 retur ...
随机推荐
- Mac上小巧实用的GIF格式录屏软件 LICEcap
LICEcap 是一款小巧使用的Mac屏幕录制软件,它以GIF格式来录制屏幕内容,用户可以自定帧率和录制范围.这样就能控制生成文件的大小,非常便捷实用哦.点击进入下载 <ignore_js_op ...
- Java学习之基本数据类型
基本类型,或者叫做内置类型,是JAVA中不同于类的特殊类型.它们是我们编程中使用最频繁的类型.java是一种强类型语言,第一次申明变量必须说明数据类型,第一次变量赋值称为变量的初始化. 1. Java ...
- MySql级联操作
转自:http://blog.csdn.net/codeforme/article/details/5539454 外键约束对子表的含义: 如果在父表中找不到候选键,则不允许在子表上进行i ...
- FusionCharts属性大全
属性的分类就以官方的API文档为准吧: 1.Chart: <1>Functional Attributes(功能属性) <2>Titles and AxisNames(标题和坐 ...
- 单例模式java实现
package Counter; public class Counter { private int counter; private static Counter instance ...
- python之面向对象那点事
一.类与对象 1.什么是类?类,顾名思义,就是具体相同属性的同一类事物的统称及抽象.对象,指是就是具体的抽象类的实例 以上的说法是不是看起来有点云里来雾里去呢.没错,专业的解释总是让人难以理解,这就是 ...
- win7中注册tomcat服务
非安装版tomcat下载后,在bin文件夹会有一个startup.bat文件,运行该文件即可启动tomcat了.不过在服务器配置tomcat的话,就通常需要注册为服务. 在/bin文件下还有tomca ...
- LINUX诞生
编辑 Linux[1] 是一类Unix计算机操作系统的统称.Linux操作系统也是自由软件和开放源代码发展中最著名的例子.在1991 年的十月,由一个名为 Linus Torvalds的年轻芬兰大学 ...
- xmemcached的time out
最近维护线上发现不停有java.util.concurrent.TimeoutException: Timed out(200) waiting for operation的问题,排查程序.配置文件的 ...
- telnet登陆路由器。。。
登陆路由有两种方式.一种是console,还有一种是使用telnet,由于我电脑是win7,不支持console.也懒得装软件,就使用telnent为例. 一.开启telnetclient 对于XP. ...