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

Description

Your friend to the south is interested in building fences and turning plowshares into swords. In order to help with his overseas adventure, they are forced to save money on buying fence posts by using trees as fence posts wherever possible. Given the locations of some trees, you are to help farmers try to create the largest pasture that is possible. Not all the trees will need to be used.

However, because you will oversee the construction of the pasture yourself, all the farmers want to know is how many cows they can put in the pasture. It is well known that a cow needs at least 50 square metres of pasture to survive.

Input

The first line of input contains a single integer, n (1 ≤ n ≤ 10000), containing the number of trees that grow on the available land. The next n lines contain the integer coordinates of each tree given as two integers x and y separated by one space (where -1000 ≤ x, y ≤ 1000). The integer coordinates correlate exactly to distance in metres (e.g., the distance between coordinate (10; 11) and (11; 11) is one metre).

Output

You are to output a single integer value, the number of cows that can survive on the largest field you can construct using the available trees.

Sample Input

4
0 0
0 101
75 0
75 101

Sample Output

151

题意:在一个树林里面养牛,每头牛需要50平方米的空间,问你总共可以养多少牛?
题解:凸包面积/50
#include <iostream>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
const int N = ;
const double eps = 1e-;
struct Point {
int x,y;
}p[N],Stack[N];
int n;
int cross(Point a,Point b,Point c){
return (a.x-c.x)*(b.y-c.y)-(a.y-c.y)*(b.x-c.x);
}
double getarea(Point a,Point b,Point c){
return cross(a,b,c)/2.0;
}
double dis(Point a,Point b){
return sqrt((double)((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)));
}
int cmp(Point a,Point b){
if(cross(a,b,p[])>) return ;
if(cross(a,b,p[])==&&dis(b,p[])-dis(a,p[])>eps) return ;
return ;
}
int Graham(){
int k=;
for(int i=;i<n;i++){
if(p[i].y<p[k].y||(p[i].y==p[k].y)&&(p[i].x<p[k].x)) k=i;
}
swap(p[],p[k]);
sort(p+,p+n,cmp);
int top =;
Stack[] = p[];
Stack[] = p[];
Stack[] = p[];
for(int i=;i<n;i++){
while(top>=&&cross(p[i],Stack[top],Stack[top-])>=) top--;
Stack[++top] = p[i];
}
double area = ;
for(int i=;i<top;i++){
area+=getarea(Stack[i],Stack[i+],Stack[]); ///这里打成p..WA了几次..
}
return floor(area/);
}
int main()
{
while(scanf("%d",&n)!=EOF){
for(int i=;i<n;i++){
scanf("%d%d",&p[i].x,&p[i].y);
}
if(n==||n==) {
printf("0\n");
continue;
}
int ans = Graham();
printf("%d\n",ans);
}
return ;
}

poj 3348(凸包面积)的更多相关文章

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

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

  2. POJ 3348 /// 凸包+多边形面积

    题目大意: 给定的n个点 能圈出的最大范围中 若每50平方米放一头牛 一共能放多少头 求凸包 答案就是 凸包的面积/50 向下取整 /// 求多边形面积// 凹多边形同样适用 因为点积求出的是有向面积 ...

  3. POJ 3348 - Cows 凸包面积

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

  4. POJ 3348 Cows 凸包 求面积

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

  5. poj 3348 Cow 凸包面积

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

  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

    题目大意: 给你n棵树,可以用这n棵树围一个圈,然后在圈里面可以养牛,每个牛需要50平方米的空间,问最多可以养多少牛? 其实就是求一个凸包,计算凸包面积,然后除以50,然后就得到答案,直接上模板了. ...

  9. poj 1265 Area 面积+多边形内点数

    Area Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5861   Accepted: 2612 Description ...

随机推荐

  1. [bzoj3371][poj2009][Usaco2004 Mar]Moo University - Emergency Pizza Order 定制比萨饼

    标题这么长的..真是让感觉人头大脚轻. 贴题面先. Description     Moo大学的餐厅必须为$C(1\leq C\leq 1000)$头入学的奶牛新生定制比萨饼.比萨饼可以在比萨小屋订做 ...

  2. 一步一步学Linq to sql(一):预备知识

    什么是Linq to sql Linq to sql(或者叫DLINQ)是LINQ(.NET语言集成查询)的一部分,全称基于关系数据的 .NET 语言集成查询,用于以对象形式管理关系数据,并提供了丰富 ...

  3. UOJ #2321. 「清华集训 2017」无限之环

    首先裂点表示四个方向 一条边上都有插头或者都不有插头,相当于满足流量平衡 最大流 = 插头个数*2时有解 然后求最小费用最大流 黑白染色分别连原点汇点

  4. 很全的 Python 面试题

    很全的 Python 面试题 Python语言特性 1 Python的函数参数传递 看两个例子:           Python   1 2 3 4 5 a = 1 def fun(a):      ...

  5. 这是我见过最厉害的--智能代码生成器、html+js+底层+sql全都有、瓦特平台

    1:直接上图.图片有点多.我就没全部上传了. (demo.使用方法.数据库bak)下载:http://pan.baidu.com/s/1ntE5bDn 起源: 之前有好多人问我代码生成器的源码.我发了 ...

  6. 《Cracking the Coding Interview》——第9章:递归和动态规划——题目7

    2014-03-20 03:35 题目:实现画图的Flood Fill操作. 解法:DFS和BFS皆可,但BFS使用的队列在时间复杂度上常数项比较大,速度略慢,所以我选了DFS.当然,如果图很大的话D ...

  7. 解决ubuntu发热严重的问题

    对于双显卡PC安装ubuntu ,风扇狂转,发热严重,原因基本双显卡的优化导致. 解决具体步骤如下: 命令行输入sudo apt-get install bumblebee bumblebee-nvi ...

  8. win10&hyper上装Ubuntu出现没有找到dev fd0, sector 0 错误

    win10 hyper装 ubuntu blk_update_request:I/O error,dev sr0,sector0 错误 配置好安装重启后出现 blk_update_request: I ...

  9. js万年历

    首先,注意: 1.延迟执行     window.setTimeout(    ,     )     里面的时间是以毫秒计算的 2.间隔执行    window.setInterval(     , ...

  10. 【现代程序设计】homework-01

    HOMEWORK-01 1) 建立 GitHub 账户, 把课上做的 “最大子数组之和” 程序签入 已完成. 2) 在 cnblogs.com 建立自己的博客. 写博客介绍自己的 GitHub 账户. ...