Uva 10112 Myacm Triangles

题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1053
题意:给一堆点,求这些点构成的面积最大且不包含其他点的三角形。
题解:数据量15,直接O(n4)枚举。
代码:
#include
#include
#include
#include
#include
using namespace std;
struct Point
{
    double x,y;
    char s;
    Point(double x=0,double y=0,char s='\0'):x(x),y(y),s(s) {} //构造函数
};
typedef Point Vector;
Vector operator + (Vector A,Vector B)
{
    return Vector(A.x+B.x,A.y+B.y);
}
Vector operator - (Point A,Point B)
{
    return Vector(A.x-B.x,A.y-B.y);
}
double Cross(Vector A,Vector B)
{
    return A.x*B.y-A.y*B.;
}
//利用叉积求三角形面积
double Area2(Point A,Point B,Point C)
{
    return fabs(Cross(B-A,C-A))/2;
}
bool judge(Point A,Point B,Point C,Point p)
{
    bool flag1=Cross(p-A,B-A)<=0&&Cross(p-B,C-B)<=0&&Cross(p-C,A-C)<=0;
    bool flag2=Cross(p-A,B-A)>=0&&Cross(p-B,C-B)>=0&&Cross(p-C,A-C)>=0;
    return flag1||flag2;
}
int main()
{
    int n;
    while(cin>>n&&n)
    {
        Point P[n];
        for(int i=0; i


你可能感兴趣的:(《算法竞赛入门经典》题目)