POJ - 2007 极角排序(Java 实现)
将所有的点按逆时针输出
import java.io.*;
import java.util.*;
public class Main {
static class Point implements Comparable<Point>{
double x, y;
@Override
public int compareTo(Point a) {
return (int)cross(a);
}
public double cross(Point a){
return a.x*y-x*a.y;
}
}
static final int N = 10005;
static final int inf = 0x3f3f3f3f;
static final double eps = 1e-6;
static Point a[] = new Point[N];
public static void main(String[] args) {
Scanner cin = new Scanner(new InputStreamReader(System.in));
int n = 0;
while (cin.hasNext()) {
if (a[n] == null)
a[n] = new Point();
a[n].x = cin.nextDouble();
a[n].y = cin.nextDouble();
n++;
}
Arrays.sort(a, 1, n);
for (int i = 0; i < n; i++) {
System.out.printf("(%.0f,%.0f)\n", a[i].x, a[i].y);
}
cin.close();
}
}
POJ - 2007 极角排序(Java 实现)的更多相关文章
- Scrambled Polygon POJ - 2007 极角排序
题意: 给你n个点,这n个点可以构成一个多边形(但是不是按顺序给你的).原点(0,0)为起点,让你按顺序逆序输出所有点 题解: 就是凸包问题的极角排序 用double一直Wa,改了int就可以了 // ...
- poj 1696 极角排序求最长逆时针螺旋线
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4970 Accepted: 3100 Descrip ...
- poj 1696 极角排序(解题报告)
#include<iostream> #include<cmath> #include<algorithm> using namespace std; double ...
- poj 1696(极角排序)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3924 Accepted: 2457 Descrip ...
- 简单几何(极角排序) POJ 2007 Scrambled Polygon
题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...
- POJ 2007 Scrambled Polygon (简单极角排序)
题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio. ...
- poj 2007 Scrambled Polygon 极角排序
/** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 retur ...
- POJ 2007 Scrambled Polygon [凸包 极角排序]
Scrambled Polygon Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8636 Accepted: 4105 ...
- POJ 2007 Scrambled Polygon(简单极角排序)
水题,根本不用凸包,就是一简单的极角排序. 叉乘<0,逆时针. #include <iostream> #include <cstdio> #include <cs ...
随机推荐
- rsync单向同步
系统版本:Centos X64 6.4(最小化安装) 先安装依赖包 [root@localhost ~]# yum install vim wget lsof gcc make cmake makec ...
- openstack dnsmasq彭祖
Openstack dnsmasq配置域名解析,openstackdnsmasq vi /etc/nova/nova.conf 在[DEFAULT]添加 dnsmasq_config_file=/et ...
- [C++ STL] map使用详解
一.set介绍: Map由红黑树实现,其元素都是"键值/实值"所形成的一个对组(key/value pairs).每个元素有一个键,是排序准则的基础.每一个键只能出现一次,不允许重 ...
- 折半枚举(双向搜索)poj27854 Values whose Sum is 0
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 23757 Accep ...
- 题解报告:hdu 1015 Safecracker
Problem Description === Op tech briefing, 2002/11/02 06:42 CST === "The item is locked in a Kl ...
- python调用chrome ie等浏览器
chrome: 首先,要安装下谷歌浏览器,查看谷歌浏览器的版本,对应版本下载相应的chromedriver插件,http://blog.csdn.net/huilan_same/article/det ...
- java IO流 之 字节输出流 OutputString()
Java学习重点之一:OutputStream 字节输出流的使用 FileOutPutStream:子类,写出数据的通道 步骤: 1.获取目标文件 2.创建通道(如果原来没有目标文件,则会自动创建一个 ...
- 使用Micrisoft.net设计方案 第三章Web表示模式 Web模式集群详细介绍 Observer(观察器)
在面向对象的编程中,对象同时包含数据和行为,这两者一起表示业务域的特定方面.使用对象生成应用程序的优点之一是可以将所有数据操作封装在对象内.这样, 就使对象成为独立的单位,并增加了在其他应用程序中重用 ...
- mvc使用linq to sql进行sum统计遇到查询为null的问题
mvc linq to sql,linq to entity,sum,null 昨天写了段sum的统计语句, decimal sums sums = ( from fac in db.Apply wh ...
- Android开发笔记(3)——GridLayout
笔记链接:http://www.cnblogs.com/igoslly/p/6799939.html GirdLayout 计算器实例及详尽的笔记:http://www.cnblogs.com/sky ...