题意:给你一些点,这些点圈起来一个牧场,每50平方米可以放一头牛,问这些点圈起来的牧场放的牛的数量
思路:求凸包的面积然后/50再向下取整
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
struct Point
{
double x,y;
double v,L;
Point(double x = 0,double y = 0) : x(x),y(y) {}
};
typedef Point Vector;
Vector operator + (Vector a,Vector b) { return Vector(a.x+b.x,a.y+b.y) ;}
Vector operator - (Vector a,Vector b) { return Vector(a.x-b.x,a.y-b.y) ;}
Vector operator * (Vector a,double p) { return Vector(a.x*p,a.y*p) ;}
Vector operator / (Vector a,double p) { return Vector(a.x/p,a.y/p) ;}
const double eps = 1e-9;
const double PI = acos(-1.0);
double Dot(Vector a,Vector b) { return a.x*b.x + a.y*b.y ;}
double Length(Vector a) { return sqrt(Dot(a,a)) ;}
double Cross(Vector a,Vector b) { return a.x*b.y - a.y*b.x ;}
int dcmp(double x)
{
if(fabs(x) < eps) return 0;
else return x < 0 ? -1 : 1;
}
bool operator < (Point a,Point b) { return a.x < b.x || (a.x == b.x && a.y < b.y) ;}
bool operator == ( Point a, Point b) { return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0 ;}
double Angle(Vector a,Vector b) { return acos( Dot(a,b) / Length(a) / Length(b) ) ;}
double Area(Point a,Point b,Point c) { return fabs(Cross(b-a,c-a))/2 ;}
Vector Rotate(Vector a,double rad) { return Vector(a.x*cos(rad) - a.y*sin(rad),a.x*sin(rad) + a.y*cos(rad) );}
Vector Normal(Vector a)
{
double L = Length(a);
return Vector(-a.y/L,a.x/L);
}
Point GetLineIntersection(Point p,Vector v,Point q,Vector w)
{
Vector u = p - q;
double t = Cross(w,u) / Cross(v,w);
return p + v*t;
}
bool SegmentProperIntersection(Point a1,Point a2,Point b1,Point b2)
{
double c1 = Cross(a2-a1,b1-a1) ,c2 = Cross(a2-a1,b2-a1),c3 = Cross(b2-b1,a1-b1),c4 = Cross(b2-b1,a2-b1);
return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3) *dcmp(c3) < 0;
}
bool OnSengment(Point p,Point a,Point b)
{
return dcmp(Cross(p-a,b-a)) == 0 && dcmp(Dot(a-p,b-p) < 0);
}
double PolyArea(Point *p,int n)
{
double area = 0;
int i;
for(i = 0; i < n; i++)
{
area += Cross(p[i]-p[0],p[i+1]-p[0]);
}
return area/2;
}
int Chell(Point *p,int n,Point *ch)
{
int i,m = 0;
sort(p,p+n);
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];
}
int 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;
}
double Area(Point *ch,int n)
{
double ans = 0;
for(int i = 0; i < n; i++)
{
ans += Cross(ch[i] - ch[0],ch[(i+1)%n] - ch[0]);
}
return ans/2;
}
Point p[10005];
int main()
{
int n;
while(scanf("%d",&n) != EOF)
{
for(int i = 0; i < n; i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
}
Point ch[10005];
int temp = Chell(p,n,ch);
double area = Area(ch,temp);
int t = area;
printf("%d\n",(t-t%50)/50);
}
return 0;
}