/*
poj3348 Cows 凸包+多边形面积 水题
floor向下取整,返回的是double
*/
#include<stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;
const double eps = 1e-8;
struct point
{
double x,y;
};
int n;
point dian[10000+10],zhan[10000+10];
//////////////////////////////////////////////////
point *mo_dian;
double mo_distance(point p1,point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
double mo_xmult(point p2,point p0,point p1)//p1在p2左返回负,在右边返回正
{
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
} bool mo_ee(double x,double y)
{
double ret=x-y;
if(ret<0) ret=-ret;
if(ret<eps) return 1;
return 0;
}
bool mo_gg(double x,double y) { return x > y + eps;} // x > y
bool mo_ll(double x,double y) { return x < y - eps;} // x < y
bool mo_ge(double x,double y) { return x > y - eps;} // x >= y
bool mo_le(double x,double y) { return x < y + eps;} // x <= y bool mo_cmp(point a,point b) // 第一次排序
{
if( mo_ee(a.y ,b.y ) )
return mo_ll(a.x, b.x);
return mo_ll(a.y,b.y);
}
bool mo_cmp1(point a,point b) // 第二次排序
{
double len = mo_xmult(b,mo_dian[0],a);
if( mo_ee(len,0.0) )
return mo_ll(mo_distance(mo_dian[0],a),mo_distance(mo_dian[0],b));
return mo_gg(len,0.0);
}
int mo_graham(int n,point *dian,point *stk)
{
int i,top=1;
mo_dian=dian;
sort(mo_dian,mo_dian+n,mo_cmp);
sort(mo_dian+1,mo_dian+n,mo_cmp1);
stk[0]=mo_dian[0];
stk[1]=mo_dian[1];
for(i=2;i<n;++i)
{
while(top>0&&mo_xmult(mo_dian[i],stk[top-1],stk[top])<=0) --top;
stk[++top]=mo_dian[i];
}
return top+1;
}
double mo_area_polygon(point *dian,int n)
{
int i;
point yuan;
yuan.x=yuan.y=0;
double ret=0;
for(i=0;i<n;++i)
{
ret+=mo_xmult(dian[(i+1)%n],yuan,dian[i]);
}
if(ret<0) ret=-ret;
return ret/2;
}
////////
int main()
{
int i;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;++i)
{
scanf("%lf%lf",&dian[i].x,&dian[i].y);
}
int ret=mo_graham(n,dian,zhan);
double area=mo_area_polygon(zhan,ret);
printf("%.0lf\n",floor(area/50));
}
return 0;
}

poj3348 Cows 凸包+多边形面积 水题的更多相关文章

  1. POJ 3348:Cows 凸包+多边形面积

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7739   Accepted: 3507 Description ...

  2. POJ 3348 Cows(凸包+多边形面积)

    Description Your friend to the south is interested in building fences and turning plowshares into sw ...

  3. 简单几何(向量旋转+凸包+多边形面积) UVA 10652 Board Wrapping

    题目传送门 题意:告诉若干个矩形的信息,问他们在凸多边形中所占的面积比例 分析:训练指南P272,矩形面积长*宽,只要计算出所有的点,用凸包后再求多边形面积.已知矩形的中心,向量在原点参考点再旋转,角 ...

  4. POJ 3348 /// 凸包+多边形面积

    题目大意: 给定的n个点 能圈出的最大范围中 若每50平方米放一头牛 一共能放多少头 求凸包 答案就是 凸包的面积/50 向下取整 /// 求多边形面积// 凹多边形同样适用 因为点积求出的是有向面积 ...

  5. POJ 3348 Cows 凸包 求面积

    LINK 题意:给出点集,求凸包的面积 思路:主要是求面积的考察,固定一个点顺序枚举两个点叉积求三角形面积和除2即可 /** @Date : 2017-07-19 16:07:11 * @FileNa ...

  6. poj3348 Cows 凸包 叉积求多边形面积

    graham扫描法,参考yyb #include <algorithm> #include <iostream> #include <cstdio> #includ ...

  7. 简单几何(凸包+多边形面积) POJ 3348 Cows

    题目传送门 题意:求凸包 + (int)求面积 / 50 /************************************************ * Author :Running_Tim ...

  8. poj 1654 Area(计算几何--叉积求多边形面积)

    一个简单的用叉积求任意多边形面积的题,并不难,但我却错了很多次,double的数据应该是要转化为long long,我转成了int...这里为了节省内存尽量不开数组,直接计算,我MLE了一发...,最 ...

  9. POJ-3348 Cows 计算几何 求凸包 求多边形面积

    题目链接:https://cn.vjudge.net/problem/POJ-3348 题意 啊模版题啊 求凸包的面积,除50即可 思路 求凸包的面积,除50即可 提交过程 AC 代码 #includ ...

随机推荐

  1. C语言怎么计算程序所花时间

    在函数之前和之后取得系统的时间,然后相减就是函数执行时间,不过在取得系统时间的时候,最小单位是微秒 具体代码如下: #include<stdio.h> #include<iostre ...

  2. Ipv6_Only-b

    网上好多关于ipv6的资料,说半天ipv6是什么,怎么建立测试环境,,,可是没有看到具体的操作和解决的方案,这里,为大家提供一种方案,希望给大家带来帮助吧. 总的来说有三个方面需要进行检查和修改: 1 ...

  3. EntityFramework 和 linq 判断是否在指定时间段内的方法

    EntityFramework: System.Data.Objects.EntityFunctions.DiffDays(DateTime.Now, inputTime)判断当前时间与指定时间相差多 ...

  4. Jquery的attr属性

    在JS中设置节点的属性与属性值用到setAttribute(),获得节点的属性与属性值用到getAttribute(),而在jquery中,用一个attr()就可以全部搞定了,赞一个先 ^^ jque ...

  5. 用UIKIT的模态对话框要注意的地方

    XXX,晚上又搞了三个小时左右,才摸清楚. 多个ID要注意唯一性. 而在DJANGO里,每一个循环的唯一性,也有技巧性. 父循环的编号 {{ forloop.parentloop.counter }} ...

  6. 【HDU3341】 Lost's revenge (AC自动机+状压DP)

    Lost's revenge Time Limit: 5000MS Memory Limit: 65535KB 64bit IO Format: %I64d & %I64u Descripti ...

  7. I2C总线之(一)---概述

    概述: I²C 是Inter-Integrated Circuit的缩写,发音为"eye-squared cee" or "eye-two-cee" , 它是一 ...

  8. linux 网络栈中的queueing

    这篇文章详细描述了在linux网络栈中queueing,及各种保证系统吞吐量和低延迟的方法机制.

  9. Spark Streaming 结合FlumeNG使用实例

    SparkStreaming是一个对实时数据流进行高通量.容错处理的流式处理系统,可以对多种数据源(如Kdfka.Flume.Twitter.Zero和TCP 套接字)进行类似map.reduce.j ...

  10. LeetCode解题报告:Binary Tree Postorder Traversal

    Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary t ...