#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll sumx,sumy,ans;
struct node
{
int x,y;
}p[3005];
struct line
{
int x,y;
double k;
}b[3005];
bool cmp1(node p1,node p2)
{
return p1.y>p2.y;
}
bool cmp2(line l1,line l2)
{
return l1.k<l2.k;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
sort(p+1,p+n+1,cmp1);
for(int i=3;i<=n;i++)
{
for(int j=1;j<i;j++)
{
b[j].x=p[j].x-p[i].x;
b[j].y=p[j].y-p[i].y;
b[j].k=atan2(b[j].y,b[j].x);
}
sort(b+1,b+i,cmp2);
sumx=b[1].x;sumy=b[1].y;
for(int j=2;j<i;j++)
{
ans+=(ll)sumx*b[j].y-(ll)sumy*b[j].x;
sumx+=b[j].x;sumy+=b[j].y;
}
}
if(ans%2==0)printf("%lld.0\n",ans/2);
else printf("%lld.5\n",ans/2);
}
三角形计数
最新推荐文章于 2022-05-29 11:29:57 发布