您的位置:首页 > 其它

CA Loves Stick HDU - 5655

2017-06-18 01:44 260 查看

**

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: