POJ 2007

将所有的点按逆时针输出

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 实现)的更多相关文章

  1. Scrambled Polygon POJ - 2007 极角排序

    题意: 给你n个点,这n个点可以构成一个多边形(但是不是按顺序给你的).原点(0,0)为起点,让你按顺序逆序输出所有点 题解: 就是凸包问题的极角排序 用double一直Wa,改了int就可以了 // ...

  2. poj 1696 极角排序求最长逆时针螺旋线

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4970   Accepted: 3100 Descrip ...

  3. poj 1696 极角排序(解题报告)

    #include<iostream> #include<cmath> #include<algorithm> using namespace std; double ...

  4. poj 1696(极角排序)

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3924   Accepted: 2457 Descrip ...

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

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

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

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

  7. poj 2007 Scrambled Polygon 极角排序

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

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

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

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

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

随机推荐

  1. bzoj4825

    LCT 昨天调试一天没出来,今天推倒重写还是gg了,内心崩溃照着源代码抄,结果发现自己把原树fa和splay的fa一起维护,各种re... 其实我们手玩一下,发现其实树的形态变化很小,那么就可以用lc ...

  2. bzoj 1649: [Usaco2006 Dec]Cow Roller Coaster【dp】

    DAG上的dp 因为本身升序就是拓扑序,所以建出图来直接从1到ndp即可,设f[i][j]为到i花费了j #include<iostream> #include<cstdio> ...

  3. 再谈 webpack build 及 加载优化

    之前项目多,事情忙,一直没时间写博客,现在空闲下来了,总结一下 之前讲过了关于 build 压缩文件的方法,有兴趣的可以看下: 点击查看 现在讲讲一个页面的首屏加载速度该如何提升 提前说明 需要 we ...

  4. spring 嵌套事务问题

    嵌套事物总结 事物成功总结 1.内外都无try Catch的时候,外部异常,全部回滚. 2.内外都无try Catch的时候,内部异常,全部回滚. 3.外部有try Catch时候,内部异常,全部回滚 ...

  5. BFS POJ 2251 Dungeon Master

    题目传送门 /* BFS:这题很有意思,像是地下城,图是立体的,可以从上张图到下一张图的对应位置,那么也就是三维搜索,多了z坐标轴 */ #include <cstdio> #includ ...

  6. AppConfig 操作简易封装

    using System; using System.Configuration; namespace HT.IMS.Common { public class ClientConfig { ; pu ...

  7. 通过机智云APP来学习安卓

    效果非常之好,安卓6.0之后就进行了动态授权.按照网上的视频一步一步调试的非常成功,非常舒服.

  8. Android PopupWindow使用时注意

    项目中使用PopupWindown出现的坑 1.部分设备,PopWindow在Android4.0后版本,出现NullPointerException调用以下方法可解决, fixPopupWindow ...

  9. Android基础TOP5_2:MultiAutoCompleteTextView多文本自动补全文本框

    Activity: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmln ...

  10. mysql复制过滤参数说明

    参考文档: http://www.ywnds.com/?p=6945 https://stackoverflow.com/questions/23191160/whats-the-difference ...