这道题目主要用到PICK定理,即,整点多边形的面积=内部整点个数+边上的整点个数/2 - 1.
至于边上的点个数,用到GCD函数求。...貌似还有个类似的题目...
#include <iostream>
#include <string.h>
#include <math.h>
#include <stdio.h>
using namespace std
;
struct node
{
int x
,y
;
}a
,b
,c
;
int gcd(int a
,int b
)
{
if(b
==0) return a
;
else return gcd(b
,a
%b
);
}
int main()
{
int l
,num
;
while(scanf("%d %d %d %d %d %d",&a
.x
,&a
.y
,&b
.x
,&b
.y
,&c
.x
,&c
.y
)!=EOF
&& (a
.x
||a
.y
||b
.x
||b
.y
||c
.x
||c
.y
))
{
l
=gcd(abs(a
.x
-b
.x
),abs(a
.y
-b
.y
))+gcd(abs(a
.x
-c
.x
),abs(a
.y
-c
.y
))
+gcd(abs(c
.x
-b
.x
),abs(c
.y
-b
.y
));
int s
=abs((b
.x
-a
.x
)*(c
.y
-a
.y
)-(c
.x
-a
.x
)*(b
.y
-a
.y
))/2;
num
=s
+1-l
/2;
printf("%d/n",num
);
}
return 0;
}
转载请注明原文地址: https://ibbs.8miu.com/read-2218222.html