题目大意:

给定的n个点 能圈出的最大范围中

若每50平方米放一头牛 一共能放多少头

求凸包 答案就是 凸包的面积/50 向下取整

/// 求多边形面积
// 凹多边形同样适用 因为点积求出的是有向面积
double areaPg()
{
double res=;
for(int i=;i<k-;i++) // 以t[0]为划分顶点
res+=(t[i]-t[]).det(t[i+]-t[]);
return res/2.0;
}
#include <cstdio>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f
using namespace std; const double eps=1e-;
double add(double a,double b) {
if(abs(a+b)<eps*(abs(a)+abs(b))) return ;
return a+b;
}
struct P {
double x,y;
P(){};
P(double _x,double _y):x(_x),y(_y){};
P operator - (P p) {
return P(add(x,-p.x),add(y,-p.y)); }
P operator + (P p) {
return P(add(x,p.x),add(y,p.y)); }
P operator * (double d) {
return P(x*d,y*d); }
double dot(P p) {
return add(x*p.x,y*p.y); }
double det(P p) {
return add(x*p.y,-y*p.x); }
}p[], t[];
int n, k;
bool cmp(P a,P b) {
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
void andrew()
{
sort(p,p+n,cmp);
k=;
for(int i=;i<n;i++) {
while(k> && (t[k-]-t[k-]).det(p[i]-t[k-])<)
k--;
t[k++]=p[i];
}
for(int i=n-,j=k;i>=;i--) {
while(k>j && (t[k-]-t[k-]).det(p[i]-t[k-])<)
k--;
t[k++]=p[i];
}
if(n>) k--;
}
double areaPg()
{
double res=;
for(int i=;i<k-;i++)
res+=(t[i]-t[]).det(t[i+]-t[]);
return res/2.0;
}
void solve()
{
andrew();
int ans=areaPg()/;
printf("%d\n",ans);
} int main()
{
while(~scanf("%d",&n)) {
for(int i=;i<n;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
solve();
} return ;
}

POJ 3348 /// 凸包+多边形面积的更多相关文章

  1. Cows - POJ 3348(凸包求面积)

    题目大意:利用n棵树当木桩修建牛圈,知道每头牛需要50平的生存空间,求最多能放养多少头牛. 分析:赤裸裸的求凸包然后计算凸包的面积. 代码如下: --------------------------- ...

  2. poj 1654 Area 多边形面积

    /* poj 1654 Area 多边形面积 题目意思很简单,但是1000000的point开不了 */ #include<stdio.h> #include<math.h> ...

  3. poj3348 Cows 凸包+多边形面积 水题

    /* poj3348 Cows 凸包+多边形面积 水题 floor向下取整,返回的是double */ #include<stdio.h> #include<math.h> # ...

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

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

  5. poj 3348--Cows(凸包求面积)

    链接:http://poj.org/problem?id=3348 Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions:  ...

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

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

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

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

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

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

  9. poj 3348(凸包面积)

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8063   Accepted: 3651 Description ...

随机推荐

  1. Java中的线程Thread方法之---interrupt()

    前几篇都介绍了Thread中的几个方法,相信大家都发现一个相似点,那就是sleep,join,wait这样的阻塞方法都必须捕获一个InterruptedException异常,顾名思义就是一个线程中断 ...

  2. JZOJ5143:无心行挽

    Description “What’s left to do when we’ve lost all hope?”“若内心万念俱灰,是否注定无心行挽?”------来自网易云音乐<Golden ...

  3. 思维题——牛客多校第六场D

    这题的不能用二分做,因为不满足单调性的 可以用multiset做 #include<bits/stdc++.h> #define ll long long #define rep(i,a, ...

  4. js判断是否为手机端访问

    随着移动端越来越重要,pc和移动端网站后台系统可能是同一个,登录或者某个特定时期需要根据不同访问来源,跳转不同页面或者做不同的处理: 这时我们就需要js的 navigator 对象: 我们先了解一下n ...

  5. NX二次开发-UFUN获取边的端点UF_MODL_ask_edge_verts

    NX9+VS2012 #include <uf.h> #include <uf_modl.h> #include <uf_ui.h> #include <uf ...

  6. 随意从Android端抓取一些数据包看到的协议

    如题,就打开了某银行客户端,登录,查询余额,退出 打开支付宝钱包,登录,来回转账到余额宝 中间收到微信的消息 看到了以下协议: 银行客户端的:DNS (连接银行网站时使用,网站server返回也是用的 ...

  7. Unity NGUI 多个UIPanel对粒子的剪裁

    之前写过一篇单个 UIPanel 对粒子的裁剪,地址是:https://www.cnblogs.com/jietian331/p/5075487.html 但项目中有时会遇到多个UIPanel,如下面 ...

  8. jquery操作html元素之( 尺寸)

    jQuery 提供多个处理尺寸的重要方法: width() height() innerWidth() innerHeight() outerWidth() outerHeight() jQuery ...

  9. 面试总结【css篇】- css3新增特性

    1.css3中的关键帧 @keyframes规则通过在动画序列中定义关键帧(或waypoints)的样式来控制CSS动画序列中的中间步骤.这 比转换更能控制动画序列的中间步骤. @keyframes ...

  10. 基于SpringBoot的Swagger2快速入门

    1. Springboot 集成 Swagger2 1.1 导入Swagger2 依赖 <!-- https://mvnrepository.com/artifact/io.springfox/ ...