正题
题目大意
凸包的面积S,求⌊S/50⌋\left \lfloor S/50\right \rfloor⌊S/50⌋
解题思路
求凸包,然后求面积,然后求答案。
codecodecode
#include<cstdio>
#include<algorithm>
#include<cmath>
#define N 10010
using namespace std;
struct point{double x,y;
}a[N];
int n,s[N];
double ans;
double m(point x,point y,point z)
{return (x.x-z.x)*(y.y-z.y)-(y.x-z.x)*(x.y-z.y);}
double dis(point x,point y)
{return sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));}
bool cmp(point x,point y)
{double t=m(x,y,a[1]);if(t>0||t==0&&dis(x,a[1])<dis(y,a[1]))return true;else return false;
}
void init()
{scanf("%d",&n);for(int i=1;i<=n;i++){scanf("%lf%lf",&a[i].x,&a[i].y);if(a[i].y<a[1].y||a[i].y==a[1].y&&a[i].x<a[1].x)swap(a[i],a[1]);}sort(a+2,a+1+n,cmp);
}
void praham()
{s[1]=1;s[2]=2;s[3]=3;int top=3;for(int i=4;i<=n;i++){while(m(a[i],a[s[top]],a[s[top-1]])>=0)top--;s[++top]=i;}s[++top]=1;for(int i=3;i<top;i++)ans+=m(a[s[i-1]],a[s[i]],a[s[1]]);printf("%d",abs(int(ans/100.0)));
}
int main()
{init();praham();
}