您的位置:首页 > 其它

CA Loves Stick HDU - 5655

2017-08-02 20:32 176 查看
题目大意:意思非常简单,就是给你四个木棒,是否能用这四个木棒拼成一个四边形

解题思路:只需要判断最小的三条边的和是否大于第四条边就行了。但是数据给的最大是long long int,所以不能直接比较,转化一下,还有需要判断木棒中 不能有0

CA loves to play with sticks. 

One day he receives four pieces of sticks, he wants to know these sticks can spell a quadrilateral. 

(What is quadrilateral? Click here: https://en.wikipedia.org/wiki/Quadrilateral)
InputFirst line contains TT denoting
the number of testcases. 
TT testcases
follow. Each testcase contains four integers a,b,c,da,b,c,d in
a line, denoting the length of sticks. 
1≤T≤1000, 0≤a,b,c,d≤263−11≤T≤1000, 0≤a,b,c,d≤263−1
OutputFor each testcase, if these sticks can spell a quadrilateral, output "Yes"; otherwise, output "No" (without the quotation marks).
Sample Input
2
1 1 1 1
1 1 9 2


Sample Output
Yes
No


#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

long long int a[5];

int main()

{

    int T;

    scanf("%d",&T);

    while(T--)

    {

        int f1,f2,f3,f4,f5,f6;

        for(int i=0;i<4;i++)

        scanf("%lld",&a[i]);

        sort(a,a+4);  //从小到大排序

        if(a[0]==0)  //有0 肯定不能组成四边形

        {

            printf("No\n");

            continue;

        }

        if(a[0]>a[3]-a[1]-a[2])  //判断最小的三条边是否大于第四条边

            printf("Yes\n");

        else

            printf("No\n");

    }

    return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  组四边形