#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define FOR2(i,a,b) for (int i = (a); i > (b); --i) /* #define FOR(i,n) for(int i=0; i < (n); i++) #define FORD(i,n) for(int i=(n)-1; i >= 0; i--) #define FORTO(i,a,b) for (int i = (a); i <= (b); ++i) */ #define DEBUG(x) cout << '>' << #x << ' ' << x << endl; #define SIZE(x) int(x.size()) typedef pair PII; typedef long long ll; const int MAX = 147; int N; double xs[MAX], ys[MAX]; inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; } struct point { double x, y; point(): x(0), y(0) { } point(double xx, double yy): x(xx), y(yy) { } bool operator<(const point & p) const { return x < p.x || (x == p.x && y < p.y); } bool operator==(const point & p) const { return x == p.x && y == p.y; } }; struct line { point p1, p2; double get_y(double x) { return p1.y + (p2.y-p1.y)*(x-p1.x)/(p2.x-p1.x); } } lines[MAX]; int overlap(pair a, pair b) { if (a.second < a.first || b.second < b.first) return 0; int m = max(a.first, b.first), M = min(a.second, b.second); return max(0, M-m); } int main() { while (1) { scanf("%d", &N); if (!N) break; FOR(i, 0, N) scanf("%lf%lf", &xs[i], &ys[i]); xs[N] = xs[0]; ys[N] = ys[0]; int sz = 0; FOR(i, 0, N) { if (xs[i] == xs[i+1]) continue; lines[sz].p1 = point(xs[i], ys[i]); lines[sz].p2 = point(xs[i+1], ys[i+1]); if (lines[sz].p2 < lines[sz].p1) swap(lines[sz].p1, lines[sz].p2); ++sz; } //pre kazdu suradnicu vector > last, act; int res = 0; FOR(x, -100, 100+1) { vector y; //prejdem zlava FOR(i, 0, sz) if (lines[i].p1.x < x && x < lines[i].p2.x) y.push_back(lines[i].get_y(x)); else if (x == lines[i].p2.x) y.push_back(lines[i].p2.y); sort(y.begin(), y.end()); act.clear(); FOR(i, 0, y.size()) { act.push_back(make_pair(ceil(y[i]-1e-9), floor(y[i+1]+1e-9))); ++i; } FOR(i, 0, last.size()) FOR(j, 0, act.size()) res += overlap(last[i], act[j]); //prejdem zprava y.clear(); FOR(i, 0, sz) if (lines[i].p1.x < x && x < lines[i].p2.x) y.push_back(lines[i].get_y(x)); else if (x == lines[i].p1.x) y.push_back(lines[i].p1.y); sort(y.begin(), y.end()); last.clear(); FOR(i, 0, y.size()) { last.push_back(make_pair(ceil(y[i]-1e-9), floor(y[i+1]+1e-9))); ++i; } } printf("%d\n", res); } return 0; }