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

我们求出凸包以后将凸包化成三角形用叉积求面积再加和
 #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
const double eps = 1e-;
const double dblinf = 9999999999.9;
const int maxn = 1e4+;
struct Point
{
double x,y;
}p[maxn];
int stk[maxn];
int top;
int dblcmp(double k)
{
if (fabs(k)<eps) return ;
return k>?:-;
}
double multi (Point p0,Point p1,Point p2)//叉乘
{
return (p1.x-p0.x)*(p2.y-p0.y)-(p1.y-p0.y)*(p2.x-p0.x);
}
double dis (Point a,Point b)
{
return sqrt( (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
bool anglecmp (Point a,Point b)//极角排序
{
int d = dblcmp(multi(p[],a,b));
if (!d) return dis(p[],a)<dis(p[],b);
return d>;
}
int n;
int main()
{
while (~scanf("%d",&n)){
double tx = dblinf,ty = dblinf;
int k;
for (int i=;i<n;++i){
scanf("%lf%lf",&p[i].x,&p[i].y);
int d = dblcmp(ty-p[i].y);
if (!d&&dblcmp(tx-p[i].x)>){
k=i;tx = p[i].x;
}
else if (d>){
k=i;
tx = p[i].x,ty = p[i].y;
}
}
p[k].x = p[].x,p[k].y = p[].y;
p[].x = tx,p[].y = ty;
sort(p+,p+n,anglecmp);
stk[] = ,
stk[] = ;
top = ;
for (int i=;i<n;++i){
while (top>=&&dblcmp(multi(p[stk[top-]] , p[i], p[stk[top]] ))>=) top--;
stk[++top] = i;
}
double area = ;
for (int i=;i<top;++i){
area+=fabs(multi(p[stk[]] , p[stk[i]] , p[stk[i+]] ));
}
area = area /2.0;//三角形面积和别忘/2.0
printf("%d\n",(int)(area/50.0));
}
return ;
}
 

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 凸包 求多边形面积 计算几何 难度:0 Source:CCC207

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

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

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

  5. ●POJ 3348 Cows

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

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

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

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

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

  8. POJ 3348 Cows | 凸包模板题

    题目: 给几个点,用绳子圈出最大的面积养牛,输出最大面积/50 题解: Graham凸包算法的模板题 下面给出做法 1.选出x坐标最小(相同情况y最小)的点作为极点(显然他一定在凸包上) 2.其他点进 ...

  9. poj 3348 Cows 求凸包面积

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

随机推荐

  1. PHP-图片处理

    开启 GD 扩展(php_gd2.dll) 创建画布 画布:一种资源型数据,可以操作的图像资源. 创建新画布(新建) ImageCreate(宽,高); 创建基于调色板的画布. imageCreate ...

  2. JS-Promise-先上传文件再提交表单

    很久前就使用过 Bootstrap File Input 上传文件,将上传文件返回的信息和表单一并提交回去. 最开始的时候是让用户手动点上传文件,然后再点提交表单: 之后尝试了写在回调里,不过这样会写 ...

  3. npm install 安装过程卡住不动

    修改 npm 的安装目录下的 npmrc文件 增加一条 registry=http://registry.cnpmjs.org $ npm config set registry http://reg ...

  4. linux sed如何锁定某一行数据进行替换

  5. tensorflow 之Dataset数据集之批量数据

    ###生成批次数据 import tensorflow as tf '''reapt()生成重复数据集 batch()将数据集按批次组合''' file_name = ['img1','img2',' ...

  6. Numpy的基础使用

    数据分析: 是把隐藏在一些看似杂乱无章的数据背后的信息提取出来,总结出所研究对象的内在规律 数据分析的三剑客: Numpy, Pandas, Matplotlib NumPy(Numerical Py ...

  7. Mysql命令收集【重要】

    1.在linux上获取Mysql服务器状态,及版本: [root@host]# mysqladmin --version 结果信息: mysqladmin  Ver 8.42 Distrib 5.7. ...

  8. BUUCTF--刮开有奖

    文件链接:https://buuoj.cn/files/abe6e2152471e1e1cbd9e5c0cae95d29/8f80610b-8701-4c7f-ad60-63861a558a5b.ex ...

  9. 2. ZooKeeper基础

    1. ZooKeeper的特性 ZooKeeper的特性主要从会话.数据节点,版本,Watcher,ACL权限控制,集群角色这些部分来了解,其中需要重点掌握的数据节点与Watcher 1.1 会话 客 ...

  10. 几种激活Profile的方式

    方法一: 选择spring.profiles.active spring.profiles.active=prodspring.profiles.active=dev 方法二: 选择spring.pr ...