题目大意:

给定的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. C++11中的技术剖析(std bind原理简单图解)

    此文为转载,好像原出处的原文已经无法打开了. 本文解释了bind 是如何工作的.为了清晰,我对图中的语法作了一些简化(例如,省略函数调用操作符的参数类型),并且简化了 bind 的实现. bind 可 ...

  2. HTML5布局篇

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...

  3. 经典单调栈最大子矩形——牛客多校第二场H

    题目是求次大子矩形,那么在求最大子矩形的时候维护M1,M2即可 转移M2时比较的过程要注意一下 #include<bits/stdc++.h> using namespace std; # ...

  4. 模拟字典序排序——hdu6034

    #include <bits/stdc++.h> #include <iostream> using namespace std; ; ; int n; int maxj; s ...

  5. Python-爬虫-requests库用语post登录

    requests库很强大,支持HTTP连接保持和连接池,支持使用cookie保持会话,支持文件上传,支持自动确定响应内容的编码,支持国际化的URL和POST数据自动编码. 可以发送无参数的get请求, ...

  6. Python 文件处理一

    1.路径下所有文件(不包含子文件) import os dirs = os.listdir(path) 注:dirs 是一个list 2.遍历路径下所有文件 def file_name(file_di ...

  7. fping简介及使用方法

    fping命令的官网为:http://fping.org/ 历史版本下载地址:http://fping.org/dist/ 第一步:安装. wget http://fping.org/dist/fpi ...

  8. 2019-8-31-C#-字典-Dictionary-的-TryGetValue-与先判断-ContainsKey-然后-Get-的性能对比

    title author date CreateTime categories C# 字典 Dictionary 的 TryGetValue 与先判断 ContainsKey 然后 Get 的性能对比 ...

  9. JS对象 向上取整ceil() ceil() 方法可对一个数进行向上取整。 语法: Math.ceil(x) 注意:它返回的是大于或等于x,并且与x最接近的整数。

    向上取整ceil() ceil() 方法可对一个数进行向上取整. 语法: Math.ceil(x) 参数说明: 注意:它返回的是大于或等于x,并且与x最接近的整数. 我们将把 ceil() 方法运用到 ...

  10. C# interface (接口基础知识详解)

    Interface(接口) (本文转载地址:http://blog.sina.com.cn/s/blog_574c993d0100d59n.html) 介绍:C#中的接口提供了一种实现运行时的多态.通 ...