题目大意:

给定一堆树的点,找到能组合成的最大面积,一个物体占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. Service官方教程(9)绑定服务时的注意事项

    Binding to a Service Application components (clients) can bind to a service by calling bindService() ...

  2. 如何用PS快速做出3D按钮效果的图片

    1 先建立一个透明图层 2:再创建一个矩形 3:选用过喷样式 4: 双击图层并应用蓝色,记得这里应该复制下颜色的16进制值. 效果如图所示 取消光泽选项,大功告成! 最终效果如图所示,将其保存为PNG ...

  3. ArrayList、HashMap 与 员工类(程序员、经理的结合使用) 相当于集合与继承的总结

    package Day28ketangzuoye; import java.util.ArrayList; import java.util.HashMap; import java.util.Map ...

  4. 227 Basic Calculator II 基本计算器II

    实现一个基本的计算器来计算一个简单的字符串表达式. 字符串表达式仅包含非负整数,+, - ,*,/四种运算符和空格 . 整数除法仅保留整数部分. 你可以假定所给定的表达式总是有效的. 一些例子: &q ...

  5. 有关LD_LIBRARY_PATH与ld.so.conf

    我之前写过一篇关于LD_LIBRARY_PATH与gcc/g++ -L的关系的文章,于是我自己用CPACK制作了一个Debian安装包,然后我在/home/.bashrc里添加了export LD_L ...

  6. 转】Nodejs对MongoDB模糊查询

    原博文出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/page/4/ 感谢! Posted: Jul 1, 2013 Tag ...

  7. 学习笔记 第十四章 使用CSS3动画

    第14章   使用CSS3动画 [学习重点] 设计2D动画 设计3D动画 设计过渡动画 设计帧动画 能够使用CSS3动画功能设计页面特效样式 14.1  设计2D动画 CSS2D Transform表 ...

  8. BaseAdapter的优化

    传统的 package cct.commonadapter.bean; import android.content.Context; import android.view.LayoutInflat ...

  9. Android SpannableString及字体设置

    import android.content.Context; import android.graphics.Color; import android.text.SpannableString; ...

  10. Farseer.net轻量级开源框架 中级篇:BasePage、BaseController、BaseHandler、BaseMasterPage、BaseControls基类使用

    导航 目   录:Farseer.net轻量级开源框架 目录 上一篇:Farseer.net轻量级开源框架 中级篇: UrlRewriter 地址重写 下一篇:Farseer.net轻量级开源框架 中 ...