#include #include #include #include using namespace std; /* For the Java folks, just imagine that T in this function is * really 'int'. */ template < typename T > T gcd(T a, T b) { if (a == 0 && b == 0) return 1; while (b) { int t = a % b; a = b; b = t; } return a; } double xpr(double x0, double y0, double x1, double y1) { return y0 * x1 - x0 * y1; } int main(void) { int cases; cin >> cases; for (int casei = 1; casei <= cases; ++casei) { int n; cin >> n; /* We can easily compute the area and the number of boundary * points, then use those to produce the number of interior * points. */ int bound = 0; double area = 0.0; int x = 0, y = 0; for (int i = 0; i < n; ++i) { int dx, dy; cin >> dx >> dy; bound += gcd(abs(dx), abs(dy)); area += xpr(x, y, x + dx, y + dy) * 0.5; x += dx; y += dy; } area = fabs(area); int interior = (int) (area + 1 - bound / 2); printf("Scenario #%d:\n%d %d %0.1lf\n\n", casei, interior, bound, area); } return 0; }