比赛 ZLXOI2015Day2 评测结果 AAAAAAAAAA
题目名称 妹妹的饼干 最终得分 100
用户昵称 mikumikumi 运行时间 0.004 s
代码语言 C++ 内存使用 0.33 MiB
提交时间 2015-10-30 18:31:43
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
typedef long long LL;
LL N;
class poi
{
public:
	LL x,y;
}P[1100];
void read()
{
	scanf("%lld",&N);
	for(int i=1;i<=N;i++)
		scanf("%lld%lld",&P[i].x,&P[i].y);
}
LL cross(poi a,poi b,poi c)
{
	return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);
}
LL area()
{
	LL ans=0;
	poi tem;
	tem.x=tem.y=0;
	for(int i=1;i<N;i++) ans+=cross(tem,P[i],P[i+1]);
	ans+=cross(tem,P[N],P[1]);
	ans=abs(ans);
	return ans;
}
LL gcd(LL x,LL y)
{
	if(y==0) return x;
	return gcd(y,x%y);
}
LL POL()
{
	LL ans=0;
	int x,y;
	for(int i=1;i<N;i++)
	{
		x=abs(P[i+1].x-P[i].x),y=abs(P[i+1].y-P[i].y);
		ans+=gcd(x,y);
		//cout<<ans<<endl;
	}
	x=abs(P[N].x-P[1].x),y=abs(P[N].y-P[1].y);
	ans+=gcd(x,y);
	return ans;
}
void work()
{
	LL ans=0;
	ans+=area();
	ans-=POL();
	ans+=2;
	ans/=2;
	printf("%lld",ans);
}
int main()
{
    freopen("sistercookies.in","r",stdin);
	freopen("sistercookies.out","w",stdout);
	read();
	work();
	return 0;
}