题目大意:

给定一堆树的点,找到能组合成的最大面积,一个物体占50面积,求最多放多少物体

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const double eps = 1e-;
const int N = ;
double myabs(double x)
{
return x>?x:-x;
}
struct Point{
double x,y;
Point(double x= , double y=):x(x),y(y){}
};
Point p[N] , ch[N];
typedef Point Vector;
Vector operator+(Vector a , Vector b){
return Vector(a.x + b.x , a.y + b.y);
}
Vector operator-(Point a , Point b){
return Vector(a.x - b.x , a.y - b.y);
}
Vector operator*(Vector a, double b){
return Vector(a.x*b , a.y*b);
}
Vector operator/(Vector a, double b){
return Vector(a.x / b , a.y/b);
}
int dcmp(double x){
if(myabs(x) < eps) return ;
return x<?-:;
}
bool operator==(Point a ,Point b){
return dcmp(a.x-b.x) == && dcmp(a.y-b.y) == ;
}
bool operator<( Point a , Point b){
return dcmp(a.x-b.x)< || (dcmp(a.x-b.x)== && dcmp(a.y-b.y)<);
}
double Cross(Vector a , Vector b){
return a.x*b.y - b.x*a.y;
}
double get_polexy_area(Point *p , int n){
double ans = ;
for(int i=;i<n-;i++){
ans += Cross(p[i] - p[] , p[i+] - p[]);
}
return ans / ;
}
int ConvexHull(Point *p, int n) //凸包
{
sort(p, p+n);
n = unique(p, p+n) - p; //去重
int m = ;
for(int i = ; i < n; i++)
{
while(m > && Cross(ch[m-]-ch[m-], p[i]-ch[m-]) <= ) m--;
ch[m++] = p[i];
}
int k = m;
for(int i = n-; i >= ; i--)
{
while(m > k && Cross(ch[m-]-ch[m-], p[i]-ch[m-]) <= ) m--;
ch[m++] = p[i];
}
if(n > ) m--;
return m;
}
int main()
{
//freopen("test.in","rb",stdin);
int n;
while(~scanf("%d",&n)){
for(int i=;i<n;i++){
scanf("%lf%lf" , &p[i].x , &p[i].y);
}
int m = ConvexHull(p,n);
double area = get_polexy_area(ch , m);
int ans = (int)(area/);
printf("%d\n",ans);
}
return ;
}

POJ 3348 最直接的凸包问题的更多相关文章

  1. POJ 3348 - Cows 凸包面积

    求凸包面积.求结果后不用加绝对值,这是BBS()排序决定的. //Ps 熟练了template <class T>之后用起来真心方便= = //POJ 3348 //凸包面积 //1A 2 ...

  2. poj 3348 Cow 凸包面积

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8122   Accepted: 3674 Description ...

  3. POJ 3348 Cows 凸包 求面积

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

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

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

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

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

  6. poj 3348 Cows 求凸包面积

    题目链接 大意: 求凸包的面积. #include <iostream> #include <vector> #include <cstdio> #include ...

  7. 2018.07.03 POJ 3348 Cows(凸包)

    Cows Time Limit: 2000MS Memory Limit: 65536K Description Your friend to the south is interested in b ...

  8. POJ 3348 Cows | 凸包——童年的回忆(误)

    想当年--还是邱神给我讲的凸包来着-- #include <cstdio> #include <cstring> #include <cmath> #include ...

  9. poj 3348:Cows(计算几何,求凸包面积)

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6199   Accepted: 2822 Description ...

随机推荐

  1. Nuget 自定义配置(官网)

    <?xml version="1.0" encoding="utf-8"?> <configuration> <config> ...

  2. windowsEvents

    今天我们要实现这个关闭窗口的功能,就是点窗口的那个叉叉它会关闭. 设计窗口的事件就是WindowsEvents,而与之有关的监听器就是WindowsListener WindowsListener也是 ...

  3. hbase rpc这点事

    年前的时候系统梳理了一下hbase rpc的实现,并且对组里的小伙伴做了一次分享.趁着热乎劲还没完全消失殆尽,准备赶紧记录下来. hbase中rpc概况 作为一个分布式系统,hbase的设计是典型的m ...

  4. android开发学习——Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/BarcodeFormat;

    在Android Studio中,sync project没有错,但是run时会报错; http://blog.csdn.net/q568430333/article/details/50969033 ...

  5. SQL SERVER 事务例子

    存储过程格式: CREATE PROCEDURE YourProcedure AS BEGIN SET NOCOUNT ON; BEGIN TRY---------------------开始捕捉异常 ...

  6. 学习笔记 第九章 使用CSS美化表格

    第9章  使用CSS美化表格 学习重点 正确使用表格标签: 设置表格和单元格属性: 设计表格的CSS样式. 9.1 表格的基本结构 表格由行.列.单元格3部分组成,单元格时行与列交叉的部分. 在HTM ...

  7. IPython notebook快捷键(Jupyter notebook)

    转自“https://blog.csdn.net/eswai/article/details/53642802” 本文整理了神器IPython Notebook(或Jupyter Notebook)的 ...

  8. (Android MVVM)使用Data Binding Library(1)

    Data Binding Library 用官方提供的Data Binding Library,可以最大限度的减少findViewById(),setOnClickListener()之类的胶水代码, ...

  9. apache设置无缓存

    打开httpd.conf 开启扩展 确保开启 LoadModule headers_module modules/mod_headers.so 添加配置项 并添加以下配置,跟据文件类型来让浏览器每次都 ...

  10. Linq详细介绍

    声明----文档转载自:http://www.cnblogs.com/liulun/archive/2013/02/26/2909985.html 在说LINQ之前必须先说说几个重要的C#语言特性 一 ...