Language: TriangleTime Limit: 1000 MS Memory Limit: 65536 KTotal Submissions: 4203 Accepted: 1858Description: Find the number of vertices in a known three-point coordinate triangle (not counted on the edge. input Multiple groups of data. Input x1, y1, x2, y2, x3, y3 in each row, representing the lattice triangle (x1, y1), (x2, y2), (x3, y3 ), −15000 ≤ x1, y1, x2, y2, x3, y3 ≤ 15000. the data ends with 6 zeros. output each group of data outputs a row, indicating the number of points in the lattice triangle. sample Input0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Sample Output06SourceStanford Local 2004 Pick theorem: S = I + E/2-1 (E indicates the point on the edge of the point polygon, I indicates the point in the point polygon) Pick inference: point polygon S = 0.5 k (k is a positive integer) formula of number of points on edge lattice: number of points of line segments (x1, y1)-(x2, y2) = gcd (abs (x1-x2), abs (y1-y2 )) + 1 [cpp] # include <cstdio> # include <cstdlib> # include <cstring> # include <cmath> # include <iostream> # include <algorithm> # include <functional> using namespace std; # define MAXX (15000) int n; int gcd (int a, int B) {if (a <B) swap (a, B); if (B = 0) return a; else return gcd (B, a % B);} struct P {int x, y; P () {} P (int _ x, int _ y ): x (_ x), y (_ y) {} friend istream & operator> (istream & cin, P & a) {cin>. x>. y; return cin;} friend bool operator | (bool B, P & a) {return B |. x |. y ;}} a [3]; struct S {P s, t; S () {}s (P _ S, P _ t): s (_ s ), t (_ t) {} friend bool operator | (bool B, S & a) {return B |. s |. t;} friend bool operator | (S & a, S & B) {return 0 | a | B;} int dx () {return abs (t. x-s.x);} int dy () {return abs (t. y-s.y);} int E () {return gcd (dx (), dy () + 1 ;}}; struct T {S c [3]; S & operator [] (int I) {return c [I];} friend istream & operator> (istream & cin, T & c) {cin> a [0]> a [1]> a [2]; c [0] = S (a [0], a [1]); c [1] = S (a [1], a [2]); c [2] = S (a [2], a [0]); return cin ;} friend bool operator & (bool B, T & a) {return B & (a [0] | a [1] | a [2]);} int area2 () {return c [0]. s. x * c [1]. s. y + c [1]. s. x * c [2]. s. y + c [2]. s. x * c [0]. s. y-c [1]. s. x * c [0]. s. y-c [2]. s. x * c [1]. s. y-c [0]. s. x * c [2]. s. y;} www.2cto.com int E () {return c [0]. E () + c [1]. E () + c [2]. E ()-3;} double _ S () {return (double) abs (area2 ()/2;} int I () {return _ S () -E ()/2 + 1 ;}} c; int main () {while (cin> c & c) {cout <c. I () <endl;} return 0 ;}