HDU 5655 CA Loves Stick 水题

CA Loves Stick

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5655

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.
(What is quadrilateral? Click here: https://en.wikipedia.org/wiki/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

Hint

题意

给你四个边,问你能不能组成四边形。

题解:

四边形的定义就是最长边小于剩下三条边之和

两个坑点:有0,三条边之和会爆ll

代码

#include<bits/stdc++.h>
using namespace std;

void solve()
{
    long long a[4];
    for(int i=0;i<4;i++)cin>>a[i];
    sort(a,a+4);
    for(int i=0;i<4;i++)if(a[i]==0){puts("No");return;}
    if(a[3]-a[2]-a[1]<a[0])puts("Yes");
    else puts("No");
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)solve();
    return 0;
}

你可能感兴趣的:(HDU 5655 CA Loves Stick 水题)