POJ 2007 简单几何
来源:互联网 发布:手机qq显示mac在线吗 编辑:程序博客网 时间:2024/05/16 15:04
既然是整数,就不要写double了.
既然是整数,就用叉积吧,别用atan2 丢失精度.
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <string>#include <algorithm>using namespace std;const int maxn = 50+3;struct Point{ int x; int y;}p[maxn],P0;int Mult(Point p0, Point p1, Point p2) //叉积{ return (p1.x-p0.x)*(p2.y-p0.y) - (p2.x-p0.x)*(p1.y-p0.y);}int cmp(const Point &p1, const Point &p2) //排序函数{ return Mult(P0,p1,p2)>0;}int main(){#ifndef ONLINE_JUDGE freopen("in","r",stdin);#endif int n = 0; while(cin>>p[n].x>>p[n].y) { n++; } P0 = p[0]; sort(p+1,p+n,cmp); for(int i = 0; i < n; i++) { cout<<"("<<p[i].x<<","<<p[i].y<<")"<<endl; } return 0;}
我试着写了下用double的(仅仅求角度换成了double 比较斜率大小 用了精度判断(<1e-8) ) 依然WA
无解...这种题目还是老老实实 写整数的吧.多好...能不丢失精度就不丢失精度~
- POJ 2007 简单几何
- POJ 1263 简单几何?!
- POJ-2504(简单几何)
- POJ 2624 简单计算几何
- POJ 1675 简单计算几何
- POJ 2850 Stacking Cylinders 简单计算几何
- POJ 1106 Transmitters (简单计算几何)
- poj 1113 凸包+简单几何计算
- POJ 2606 Rabbit hunt【简单几何】
- POJ 1269 Intersecting Lines 简单计算几何
- poj 1127 简单几何+并查集
- 计算几何:极角排序(poj 2007 Scrambled Polygon)与简单凸包(poj 1113 Wall)
- POJ 2007 Scrambled Polygon(几何)
- POJ 2007 计算几何 叉积
- POJ-4042(简单几何)(Regular Convex Polygon )
- poj 题目2398 Toy Storage (简单计算几何)
- POJ 1264 UVA 109 简单的计算几何
- POJ 2405 Beavergnaw (计算几何-简单题)
- linux下 oracle10G 安装
- POJ 1230(贪心)
- linux下 stat statfs 获取 文件 磁盘 信息
- nginx 自定义模块
- A Source the following script
- POJ 2007 简单几何
- 判断一个序列是否是二叉查找树的后序、前序、中序遍历序列
- 树状数组 关键代码
- History命令用法
- Delphi使用全局快捷键
- Android 编程注意事项
- 工具栏上创建ComboBox组合框控件,框架响应消息
- 深入Mysql字符集设置
- How to enable the debugfs