题目大意:

给你n棵树,可以用这n棵树围一个圈,然后在圈里面可以养牛,每个牛需要50平方米的空间,问最多可以养多少牛?

其实就是求一个凸包,计算凸包面积,然后除以50,然后就得到答案,直接上模板了。

凸包这一类型的题目差不多,可以作为模板使用,时间复杂度是NlogN。

//Time 32ms; Memory 568K
#include<iostream>
#include<algorithm> using namespace std; int n; typedef struct point
{
double x,y;
point(double xx=0,double yy=0):x(xx),y(yy){}
}vector; point p[10010],ch[10010]; bool operator < (point a,point b)
{
return a.x<b.x || (a.x==b.x && a.y<b.y);
}
vector operator - (point a,point b)
{
return vector(a.x-b.x,a.y-b.y);
}
double cross(vector a,vector b)
{
return a.x*b.y-a.y*b.x;
} int graph()
{
int k,m=0,i;
for(i=0;i<n;i++)
{
while(m>1 && cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
ch[m++]=p[i];
}
k=m;
for(i=n-2;i>=0;i--)
{
while(m>k && cross(ch[m-1]-ch[m-2],p[i]-ch[m-2])<=0) m--;
ch[m++]=p[i];
}
if(n>1) m--;
return m;
}
int main()
{
int i,m,d;
double s=0;
cin>>n;
for(i=0;i<n;i++) cin>>p[i].x>>p[i].y;
sort(p,p+n);
m=graph();
for(i=1;i<m-1;i++) s+=0.5*cross(ch[i]-ch[0],ch[i+1]-ch[0]);
d=s/50;
cout<<d<<endl;
return 0;
}

POJ 3348 Cows的更多相关文章

  1. POJ 3348 - Cows 凸包面积

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

  2. POJ 3348 Cows 凸包 求面积

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

  3. ●POJ 3348 Cows

    题链: http://poj.org/problem?id=3348 题解: 计算几何,凸包,多边形面积 好吧,就是个裸题,没什么可讲的. 代码: #include<cmath> #inc ...

  4. POJ 3348 Cows [凸包 面积]

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9022   Accepted: 3992 Description ...

  5. 2018.07.03 POJ 3348 Cows(凸包)

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

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

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

  7. poj 3348 Cows 凸包 求多边形面积 计算几何 难度:0 Source:CCC207

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7038   Accepted: 3242 Description ...

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

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

  9. POJ 3348 Cows (凸包模板+凸包面积)

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

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

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

随机推荐

  1. .net mvc ajax list post

    http://stackoverflow.com/questions/13242414/passing-a-list-of-objects-into-an-mvc-controller-method- ...

  2. 关于webbrowser控件自动登陆的问题

    原文:关于webbrowser控件自动登陆的问题 楼主dtb(陈少)2004-03-04 22:16:55 在 VB / 网络编程 提问 请问怎么用webbrowser自动登陆www.jp168.co ...

  3. mysql很全的和完整的总结

    (1)数据类型 类型 备注 tinyint/smallint/mediumint/int/bigint 1B/2B/3B/4B/8B float/double 单精度/双精度浮点型 decimal 不 ...

  4. Android Notification通知详细解释

    Android Notification通知具体解释  Notification: (一).简单介绍:         显示在手机状态栏的通知. Notification所代表的是一种具有全局效果的通 ...

  5. 在C#编程中玩转枚举,分享我的EnumHelper。

    在C#编程中玩转枚举,分享我的EnumHelper. 在软件开发过程中,我们经常会为特定的场景下的特定数据定义逻辑意义.比如在用户表中,我们可能会有一个用户状态字段,该字段为整形.如果该字段的值为1则 ...

  6. TML5安全:CORS(跨域资源共享)简介

    来源:http://blog.csdn.net/hfahe/article/details/7730944 前言:像CORS对于现代前端这么重要的技术在国内基本上居然很少有人使用和提及,在百度或者Go ...

  7. TestNg的xml配置

    TestNG中,可以通过配置xml来运行某一类.包.方法. 1.通过TestNg运行某一个类 <?xml version="1.0" encoding="UTF-8 ...

  8. PHP 7: PHP 变量和常量的定义

    原文:PHP 7: PHP 变量和常量的定义 本章说说变量的定义.如果对于变量和常量的定义,你会注意几个方面呢?你可能会想到: 如何定义变量,它和C# 等语言有什么不同呢? 变量区分大小写吗? PHP ...

  9. 配置serv-u access数据库遇到的一些问题

    配置好access数据库后,需要建个web页面来供用户修改密码,但修改时,提示:odbc被占用无法打开. serv-u一直在保持打开access数据库.我们需要将数据库设置默认打开方式为共享,不锁定. ...

  10. Node填坑教程——整理文件

    如果你能把所有代码写进一个文件,并且能很好的管理.协调.多人开发.那么可以跳过这期(请务必带我飞). 我们接着完善上期的代码,给代码分家. node并没有启动入口,更没有固定的项目结构,文件配置.这些 ...