HDU 5655 CA Loves Stick

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 contains T denoting the number of test   cases.
T test   cases follow. Each test   case contains four integers a,b,c,d in 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;
}















  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值