记录编号 300113 评测结果 AAAAA
题目名称 多边形面积 最终得分 100
用户昵称 GravatarAntiLeaf 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2016-08-28 09:37:42 内存使用 0.00 MiB
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=110;
typedef struct Point{
	double x,y;
	Point(double x=0.0,double y=0.0):x(x),y(y){}
	Point(const Point &A,const Point &B):x(B.x-A.x),y(B.y-A.y){}
	Point operator-()const{
		return Point(-x,-y);
	}
	Point operator+(const Point &b)const{
		return Point(x+b.x,y+b.y);
	}
	Point operator-(const Point &b)const{
		return *this+(-b);
	}
}Vector;
double Cross(const Vector&,const Vector&);
double Area(const Point&,const Point&,const Point&);
int n;
Point a[maxn];
double ans=0.0;
inline int MAIN(){
#define MINE
#ifdef MINE
	freopen("areas.in","r",stdin);
	freopen("areas.out","w",stdout);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lf%lf",&a[i].x,&a[i].y);
	for(int i=2;i<n;i++)ans+=Area(a[1],a[i],a[i+1]);
	printf("%.0lf",ans);
	return 0;
}
double Cross(const Vector &A,const Vector &B){
	return A.x*B.y-B.x*A.y;
}
double Area(const Point &A,const Point &B,const Point &C){
	return Cross(Vector(A,B),Vector(A,C))/2.0;
}
int hzoier=MAIN();
int main(){;}