// @BEGIN_OF_SOURCE_CODE /* @JUDGE_ID: 17243NT 143 C++ "Multiply by 100 and use integers" */ // Send to judge@uva.es #include #include #include #include #ifdef ONLINE_JUDGE #define ins cin #define outs cout #else #define ins fin #define outs fout ifstream fin("myprog.in"); ofstream fout("myprog.out"); #endif #define roundint(a) ((int) (a + .5)) typedef struct { int x; int y; } point; int isbtwn(point p, point l1, point l2) { if((l2.y - l1.y) * (l2.x - p.x) != (l2.y - p.y) * (l2.x - l1.x)) return false; if(p.x < l1.x && p.x < l2.x) return false; if(p.y < l1.y && p.y < l2.y) return false; if(p.x > l1.x && p.x > l2.x) return false; if(p.y > l1.y && p.y > l2.y) return false; return true; } int isleft(point P0, point P1, point P2) { return ((P1.x - P0.x) * (P2.y - P0.y) - (P2.x - P0.x) * (P1.y - P0.y) ); } int inpoly(point P, point V[], int n) { int wn = 0; for(int i = 0; i < n; i++) { if(V[i].y <= P.y) { if(V[i + 1].y > P.y) if(isleft(V[i], V[i + 1], P) > 0) wn++; } else { if(V[i + 1].y <= P.y) if(isleft(V[i], V[i + 1], P) < 0) wn--; } } return wn; } int main() { point vertex[4]; double x1, y1, x2, y2, x3, y3; int count, x, y; while(ins >> x1 >> y1 >> x2 >> y2 >> x3 >> y3) { if(x1 == 0 && x2 == 0 && x3 == 0 && y1 == 0 && y2 == 0 && y3 == 0) break; vertex[0].x = roundint(x1 * 100); vertex[0].y = roundint(y1 * 100); vertex[1].x = roundint(x2 * 100); vertex[1].y = roundint(y2 * 100); vertex[2].x = roundint(x3 * 100); vertex[2].y = roundint(y3 * 100); vertex[3].x = roundint(x1 * 100); vertex[3].y = roundint(y1 * 100); count = 0; for(x = 1; x < 100; x++) for(y = 1; y < 100; y++) { point pt = {100 * x, 100 * y}; if(inpoly(pt, vertex, 3) || isbtwn(pt, vertex[0], vertex[1]) || isbtwn(pt, vertex[1], vertex[2]) || isbtwn(pt, vertex[0], vertex[2])) { count++; } } outs << setw(4) << count << endl; } return 0; } // @END_OF_SOURCE_CODE