CA Loves Stick

Problem Description
CA loves to play with sticks.
One day he receives four pieces of sticks, he wants to know these sticks can spell a quadrilateral.

Input
First line contains T denoting the number of testcases.
T testcases follow. Each testcase contains four integers a,b,c,d in a line, denoting the length of sticks.
1≤T≤1000, 0≤a,b,c,d≤263−1

Output
For 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
题意:给你四个数(long long型)问你是否能组成四边形
这是代码:

#include 
#include 
#include 
#include 
using namespace std;
int main()
{
    int n;
    long long a[4];
    while(~scanf("%d", &n))
    {
        while(n--)
        {
            scanf("%I64d %I64d %I64d %I64d", &a[0], &a[1], &a[2], &a[3]);
            sort(a, a + 4);
            if(!a[0] || !a[1] || !a[2] || !a[3]) puts("No");//四个数不能是0
            else
            {
                if((a[3] - a[2] - a[1]) < a[0]) puts("Yes");//四边形的判断条件
                else puts("No");
            }
        }

    }
    return 0;
}

这道题我们全军覆没,比赛完之后,看了大神的代码然后再讨论了一下才发现没必要用unsigned long long即用大数据算,直接把等式左右移动一下就OK了,然后四边形的判断条件就像三角形一样,任意三边之和大于另一条边,
然后AC了。

你可能感兴趣的:(原创,编程,杭电题,水题)