CF 6 A. Triangle

题目:Triangle

呵呵 原来 degenerate triangle 是小的两边之和等于第三边的情况...

 

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int seg[4];
bool is_ok(int a,int b,int c)
{
    if(a+b>c)
        return true;
    return false;;
}
bool judge_one()
{
    for(int i=0;i<4;i++)
        for(int j=i+1;j<4;j++)
            for(int k=j+1;k<4;k++)
                if(is_ok(seg[i],seg[j],seg[k]))
                {
                    return true;
                }
    return false;
}
bool judge_two()
{
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<4;j++)
        {
            if(j==i)
                continue;
            for(int k=j+1;k<4;k++)
            {
                if(k==i)
                    continue;
                for(int l=k+1;l<4;l++)
                {
                    if(l==i)
                        continue ;
                    if(seg[j]+seg[k]==seg[l])
                        return true;
                }
            }
        }
    }
    return false;
}
int main()
{
    for(int i=0;i<4;i++)
        scanf("%d",&seg[i]);
    sort(seg,seg+4);
    if(judge_one())
        printf("TRIANGLE
");
    else if(judge_two())
        printf("SEGMENT
");
    else
        printf("IMPOSSIBLE
");
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/overflow/p/3191127.html