#include #include #include #include #include using namespace std; #define M_PI 3.1415926535 #define FNAME "circle.txt" #define cin fin ifstream fin(FNAME); class Point { public: int x, y; Point() {} Point( int x, int y ) : x(x), y(y) {} bool operator < ( const Point &p ) const { if ( x < p.x ) return true; if ( x > p.x ) return false; return (y < p.y); } }; int p1, p2a, p2b, p3, p4; bool existPoint( const set &S, int x, int y ) { return (S.find(Point(x, y)) != S.end()); } void count( bool lu, bool lb, bool ru, bool rb ) { int non = 0; if ( lu ) non++; if ( lb ) non++; if ( ru ) non++; if ( rb ) non++; if ( non == 1 ) p1++; else if ( non == 3 ) p3++; else if ( non == 4 ) p4++; else if ( lb && ru || lu && rb ) p2b++; else p2a++; } void compute( const Point &p, const set &S ) { const int x = p.x; const int y = p.y; count(existPoint(S, x-1, y+1), existPoint(S, x-1, y), existPoint(S, x, y+1), existPoint(S, x, y)); count(existPoint(S, x-1, y), existPoint(S, x-1, y-1), existPoint(S, x, y), existPoint(S, x, y-1)); count(existPoint(S, x, y+1), existPoint(S, x, y), existPoint(S, x+1, y+1), existPoint(S, x+1, y)); count(existPoint(S, x, y), existPoint(S, x, y-1), existPoint(S, x+1, y), existPoint(S, x+1, y-1)); } int main() { int npoint; const double a1 = M_PI/4; const double a2a = sqrt(3.0)/4 + M_PI/6; const double a2b = 1.0; const double a3 = 1.0; const double a4 = 1.0; for ( int n = 1; cin >> npoint && npoint != 0; n++ ) { vector P; set S; Point p; for ( int i = 0; i < npoint; i++ ) { cin >> p.x >> p.y; P.push_back(p); S.insert(p); } p1 = p2a = p2b = p3 = p4 = 0; for ( int i = 0; i < npoint; i++ ) compute(P[i], S); p2a /= 2; p2b /= 2; p3 /= 3; p4 /= 4; const double area = p1*a1 + p2a*a2a + p2b*a2b + p3*a3 + p4*a4; if ( n > 1 ) printf("\n"); printf("Data set #%d: Total area = %.4lf square meters.\n", n, area); } return 0; }