http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19099
Given some points, the maximum area of the triangle is formed, and the triangle cannot contain other points (not on the edge).
Because the data range is small, the direct enumeration is good, and the area formula tells us that the method of judging the point in the triangle is that the sum of the area of the point and other vertices is equal to the area of the triangle.
#include <cstdio> #include <cmath>struct point{char z; int x, y;} P[20];d ouble Area (point A,point b,point c) {return fabs (0.5* (C.Y-A.Y) * (b.x-a.x)-(B.Y-A.Y) * (c.x-a.x));} BOOL Check (point a,point b,point c,point D) {if (area (a,b,d) +area (b,d,c) +area (a,d,c)) ==area (A,B,C)) return 1; else return 0;} int main () {//freopen ("A.txt", "R", stdin); int n,i,j,k,l; while (~SCANF ("%d", &n)} {if (n==0) break; GetChar (); for (i=0;i<n;i++) {scanf ("%c%d%d", &p[i].z,&p[i].x,&p[i].y); printf ("%c%d%d\n", p[i].z,p[i].x,p[i].y); GetChar (); } double s,sum=0; Char a,b,c; for (i=0;i<n;i++) {for (j=i+1;j<n;j++) {for (k=j+1;k<n;k++) {S=area (p[i],p[j],p[k]); if (s>sum) {for (l=0;l<n;l++) { if (L!=i&&l!=j&&l!=k&&check (P[i],p[j],p[k],p[l])) break; } if (l==n) {sum=s; A=p[i].z; B=p[j].z; C=p[k].z; }}}}} printf ("%c%c%c\n", a,b,c); } return 0;}
UVA-10061 how many Zero's and how many digits?