CA Loves Stick HDU

来源:互联网 发布:indesign cs4 mac 编辑:程序博客网 时间:2024/06/05 02:06

**


Problem

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 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−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

ps:水题,用减法,加法会爆,先排序再比较

代码如下:

#include<cstdio>#include<algorithm>using namespace std;int main () {    long long n;    scanf("%d", &n);    while( n-- ) {        long long a[5];        for(int i = 0; i <= 3; i++) scanf("%lld", &a[i]);        if(a[0] == 0) {            printf("No\n");            continue;        }        sort(a, a+4);//      printf("%lld %lld %lld %lld\n", a[0], a[1], a[2], a[3]);         if(a[3]-a[2]-a[1]<a[0]) printf("Yes\n");        else printf("No\n");    }     return 0;} 
原创粉丝点击