http://poj.org/problem?id=2954 匹克定理求多边形内部点的个数 //匹克定理S = A + E/2 - 1 //S表示多边形面积 //A表示多边形内部的点的个数 //E表示在多边形上的点的个数 //A = S - E/2 + 1 #include<iostream> #include<math.h> using namespace std; int x1, yy, x2, y2, x3, y3; int area() { return abs((x1-x2) * (y2-y3) - (x2-x3) * (yy-y2)); } int gcd(int a, int b) { if(!b) { return a; } else { return gcd(b, a%b); } } int onEdge() { int E = 0; E += gcd(abs(x1-x2), abs(yy-y2)); E += gcd(abs(x2-x3), abs(y2-y3)); E += gcd(abs(x3-x1), abs(y3-yy)); return E; } int main() { //freopen("in.txt", "r", stdin); int S, E, A; while(scanf("%d%d%d%d%d%d", &x1, &yy, &x2, &y2, &x3, &y3) != EOF) { if(x1 == 0 && x1 == x2 && x1 == x3 && x1 == yy && x1 == y2 && x1 == y3) { break; } S = area() / 2; E = onEdge(); A = S - E/2 + 1; printf("%d/n", A); } return 0; }