HDU 5655 CA Loves Stick

来源:互联网 发布:电脑优化软件知乎 编辑:程序博客网 时间:2024/06/08 01:34

CA Loves Stick

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 2934    Accepted Submission(s): 820


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

Input
First line containsTdenoting the number of test cases.
T test cases follow. Each test case contains four integers a,b,c,din a line, denoting the length of sticks.
1<=T<=20,0<=a,b,c,d<=2^63-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


/*题目大意:给定四条线段的长度,判断能否拼接成一个四边形水题,判断条件为三条短边之和大于第四边,即a0+a1+a2>a3;有一个坑点,数据范围最大为2^63-1,若a0+a1+a2,有超long long的可能,通过简单的移项即可解决。*/#include<stdio.h>#include<iostream>#include<algorithm>using namespace std;int main(){    int t;    long long a[10];    scanf("%d",&t);    while(t--){        cin>>a[0]>>a[1]>>a[2]>>a[3];        sort(a,a+4);        if(a[0]==0){            printf("No\n");        }        else{            if(a[3]-a[2]-a[1]<a[0]){                printf("Yes\n");            }            else{                printf("No\n");            }        }    }    return 0;}















原创粉丝点击