www.pudn.com > zju_1000_1010.rar > 1010_smh.CPP
//Area //18615 2002-05-30 08:25:14 Accepted 1010 C++ 00:00.22 464K jet_engine #include#include #include struct point{ double x,y;}; point plist[1001]; double distant(point s, point e) // calc distance { return (sqrt((s.x-e.x)*(s.x-e.x)+(s.y-e.y)*(s.y-e.y))); } double AOT(point p1, point p2, point p3) // area of triangle { return ((p2.x-p1.x)*(p3.y-p2.y)-(p2.y-p1.y)*(p3.x-p2.x))/2.0; } double area_cal(int sum) // polygon area calculation { // not proofed but work ok double area=0.0; for (int i=1; i -1e-10&&d1<1.0000000001&&d2>-1e-10&&d2<1.0000000001){// within // the intersection happen to be on the vertex of both lines if ((same(d1,0)||same(d1,1))&&(same(d2,0)||same(d2,1))) return 0; // else return 1; } return 0; } int possible(int sum) { point s1,s2,e1,e2; //start ----- end int i, j; for (i=0; i >sum; for (i=0; i >plist[i].x>>plist[i].y; for (j=0; j1) cout<