#include typedef struct _pair_r { int s, e; } pair_t; int n_pair[4000]; pair_t pair[4000][500]; typedef struct _point_t { int x, y; } point_t; typedef struct _line_t { point_t p1, p2; } line_t; typedef struct _poly_t { point_t p[128]; int n; } poly_t; int ccw(point_t p0, point_t p1, point_t p2) { int dx1, dx2, dy1, dy2; dx1 = p1.x - p0.x; dy1 = p1.y - p0.y; dx2 = p2.x - p0.x; dy2 = p2.y - p0.y; if (dx1*dy2 > dy1*dx2) return +1; if (dx1*dy2 < dy1*dx2) return -1; if ((dx1*dx2 < 0) || (dy1*dy2) < 0) return -2; if ((dx1*dx1+dy1*dy1) < (dx2*dx2+dy2*dy2)) return +2; return 0; } int intersect(line_t l1, line_t l2) { return (((ccw(l1.p1,l1.p2,l2.p1) * ccw(l1.p1,l1.p2,l2.p2)) <= 0) && ((ccw(l2.p1,l2.p2,l1.p1) * ccw(l2.p1,l2.p2,l1.p2)) <= 0)); } int intersect2(line_t l1, line_t l2) { return (((ccw(l1.p1,l1.p2,l2.p1) * ccw(l1.p1,l1.p2,l2.p2)) == -1) && ((ccw(l2.p1,l2.p2,l1.p1) * ccw(l2.p1,l2.p2,l1.p2)) == -1)); } int inside(point_t t, poly_t p) { int i, count = 0, j = 0; line_t lt, lp; p.p[p.n] = p.p[0]; p.p[p.n+1] = p.p[1];p.p[p.n+2] = p.p[2]; lt.p1 = t; lt.p2 = t; lt.p2.x = 5000; for (i = 0; i < p.n; i++) { if (ccw(p.p[i], p.p[i+1], t) % 2 == 0) { return 0; } } if (ccw(lt.p1, lt.p2, p.p[0]) == 0) { for (i = 2; i <= p.n+1; i++) { lp.p1 = p.p[i]; lp.p2 = p.p[i]; if (ccw(lt.p1, lt.p2, p.p[i]) != 0) { if (i == j+1) { lp.p2 = p.p[j]; if (intersect(lp,lt)) { count++; } } else { if (ccw(lt.p1, lt.p2, p.p[i]) * ccw(lt.p1, lt.p2, p.p[j]) < 0) { count++; } } j = i; } } return count&1; } for (i = 1; i <= p.n; i++) { lp.p1 = p.p[i]; lp.p2 = p.p[i]; if (ccw(lt.p1, lt.p2, p.p[i]) != 0) { if (i == j+1) { lp.p2 = p.p[j]; if (intersect(lp,lt)) { count++; } } else { if (ccw(lt.p1, lt.p2, p.p[i]) * ccw(lt.p1, lt.p2, p.p[j]) < 0) { count++; } } j = i; } } return count & 1; } int complete(int x, int y, poly_t p) { int dx, dy; point_t t; for (dy = 0; dy < 2; dy++) { for (dx = 0; dx < 2; dx++) { t.x = x+dx*2; t.y = y+dy*2; if (inside(t, p)) { return 1; } } } return 0; } int cross(int x, int y, poly_t p) { int dx[5] = {0,2,2,0,0}; int dy[5] = {0,0,2,2,0}; int l, i; line_t l1, l2; p.p[p.n] = p.p[0]; p.p[p.n+1] = p.p[1]; for (l = 0; l < p.n; l++) { for (i = 0; i < 4; i++) { l1.p1.x = x+dx[i]; l1.p1.y = y+dy[i]; l1.p2.x = x+dx[i+1]; l1.p2.y = y+dy[i+1]; l2.p1 = p.p[l]; l2.p2 = p.p[l+1]; if (intersect2(l1, l2)) { return 1; } } } return 0; } int naname(int x, int y, poly_t p) { point_t s, t; int l, i; p.p[p.n] = p.p[0]; p.p[p.n+1] = p.p[1]; s.x = x; s.y = y; t.x = x+2; t.y = y+2; for (l = 0; l < p.n; l++) { if (ccw(p.p[l], p.p[l+1], s) == 0 && ccw(p.p[l], p.p[l+1], t) == 0) { return 1; } } s.x = x+2; s.y = y; t.x = x; t.y = y+2; for (l = 0; l < p.n; l++) { if (ccw(p.p[l], p.p[l+1], s) == 0 && ccw(p.p[l], p.p[l+1], t) == 0) { return 1; } } return 0; } int center(int x, int y, poly_t p) { point_t t; t.x = x+1; t.y = y+1; if (inside(t, p)) { return 1; } return 0; } int main() { int i, n, x, y, maxx, maxy, minx, miny, done; poly_t p; point_t t, h; int sum; freopen("area.txt", "r", stdin); while (1) { scanf("%d", &p.n); if (p.n == 0) break; maxx = maxy = -4000; minx = miny = 4000; for (i = 0; i < p.n; i++) { scanf("%d %d", &(p.p[i].x), &(p.p[i].y)); p.p[i].x *= 2; p.p[i].y *= 2; if (maxx < p.p[i].x) maxx = p.p[i].x; if (minx > p.p[i].x) minx = p.p[i].x; if (maxy < p.p[i].y) maxy = p.p[i].y; if (miny > p.p[i].y) miny = p.p[i].y; } sum = 0; for (t.y = maxy + 2; t.y >= miny - 2; t.y-=2) { for (t.x = minx - 2; t.x <= maxx + 2; t.x+=2) { if (complete(t.x, t.y, p) || cross(t.x, t.y, p) || naname(t.x, t.y, p) || center(t.x, t.y, p)) { sum++; } } } printf("%d\n", sum); } return 0; }