poj 3348
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=10005;
const double PI=acos(-1);
struct point
{
double x;
double y;
};
point p[maxn];
point s[maxn];
double cross(point p0,point p1,point p2) //叉积.
{
return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
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 cmp(point p1,point p2) //按照斜率排序。
{
if(cross(p1,p2,p[0])>0||(cross(p1,p2,p[0])==0&&(dis(p1,p[0])<dis(p2,p[0]))))
return true;
return false;
}
double max(double a,double b)
{
if(a>b) return a;
return b;
}
int graham(int n)
{
int top,i,tmp=0;
for(i=1;i<n;i++) //找基点。
{
if((p[i].y<p[tmp].y)||((p[i].y==p[tmp].y)&&(p[i].x<p[tmp].x)))
tmp=i;
}
swap(p[0],p[tmp]);
sort(p+1,p+n,cmp); //按斜率排序。
top=1;
s[0]=p[0];
s[1]=p[1];
for(i=2;i<n;i++)
{
while(top&&cross(s[top-1],s[top],p[i])<=0)
top--;
s[++top]=p[i];
}
return top;
}
int main()
{
//freopen("Input.txt","r",stdin);
int n,i,tt;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
tt=graham(n);
double area=0;
for(i=1;i<tt;i++) //用叉积求面积。
area+=cross(s[0],s[i],s[i+1])/2;
printf("%d\n",(int)(area/50)); //结果向下取整,但是用floor就是错。
}
return 0;
}