POJ 3348 Cows(凸包面积)
来源:互联网 发布:数据库的模型 编辑:程序博客网 时间:2024/06/05 06:45
题意:求凸包面积/50,取整
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <stack>using namespace std;double EPS = 1e-12;struct cpoint{ double x,y; void get(){scanf("%lf%lf",&x,&y);}};double x_mult(cpoint a,cpoint b,cpoint c){ return (a.x-c.x)*(b.y-c.y)-(a.y-c.y)*(b.x-c.x);}int cmp(cpoint const a,const cpoint b){ return a.y<b.y||(a.y==b.y&&a.x<b.x);}int granham(cpoint p[],int s,cpoint r[]){ int i,len,top = 1; sort(p,p+s,cmp); r[0]= p[0],r[1] = p[1]; if(s<3) return s; for(i=2;i<s;i++) { while(top&&x_mult(p[i],r[top],r[top-1])>EPS) top--; r[++top] = p[i]; } len = top;r[++top] = p[s-2]; for(i=s-3;i>=0;i--) { while(top!=len&&x_mult(p[i],r[top],r[top-1])>EPS) top--; r[++top] = p[i]; } return top;}double area(cpoint p[],int s){ double ret=0; if(s<3) return 0; for(int i=1;i<s-1;i++) { ret+=x_mult(p[i],p[i+1],p[0]); }ret/=2; return ret;}cpoint p[10009],ans[10009];int main(){ freopen("in.txt","r",stdin); int n; scanf("%d",&n); for(int i=0;i<n;i++) p[i].get(); int k = granham(p,n,ans); double a = area(ans,k); printf("%d\n",int(a/50)); return 0;}
- POJ 3348 Cows(凸包面积)
- Poj 3348 Cows (凸包面积)
- POJ 3348 Cows (凸包面积)
- POJ 3348 Cows (凸包面积)
- POJ 3348 Cows(凸包+多边形面积)
- POJ 3348 Cows(凸包面积)
- POJ 3348 Cows(凸包面积)
- POJ 3348:Cows 凸包+多边形面积
- POJ 3348 Cows (凸包面积)
- poj 3348 Cows (凸包面积)
- POJ 3348 Cows (凸包面积)
- POJ 3348 Cows 寻找凸包 凸包面积
- POJ 3348 Cows (计算凸包面积)
- poj 3348 Cows(凸包+叉积求面积)
- POJ 3348 Cows 凸包+求多边形面积
- POJ 3348 Cows 凸包 + 多边形面积公式
- poj 3348 Cows 求凸包以及凸包的面积
- POJ 3348 Cows (凸包+求面积)
- Ajax技术的基础
- Jsp中引入JavaScript失败(找不到js文件)
- 18哥公益PHP
- 排序二叉树的插入和删除
- js图片之onload技术
- POJ 3348 Cows(凸包面积)
- 推荐 15 款很棒的文本编辑器
- Diagnostics.StackTrace指定堆栈帧
- zlib库剖析(1):实现概览
- 应用系统之间数据传输的几种方式
- zlib库剖析(2):编译及应用
- 软件开发过程及几个常见的开发模型(软件工程学习笔记)
- 我的android应用-HiBabyDragon(三) - 源码
- 独自等待(续)