CA Loves Stick
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 498 Accepted Submission(s): 181
By NanoApe构成四边形的条件:最长边小于其余三条边的和
坑点1:假如有条长度为0的边的话,哪里来的四条边呢?
坑点2:其余三条边的和会爆longlong,我们可以将a+b+c>d换成a>d-b-c来求解
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 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
Sample Output
Source
BestCoder Round #78 (div.2)
Recommend
wange2014 | We have carefully selected several similar problems for you: 5659 5658 5657 5654 5653
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
int main()
{
LL A[5];
int t;
cin>>t;
while(t--)
{
cin>>A[0]>>A[1]>>A[2]>>A[3];
sort(A,A+4);
if(A[0]<=0)
{
printf("No\n");
continue;
}
if(A[3]-A[2]-A[1]>A[0])
{
printf("No\n");
}
else
printf("Yes\n");
}
return 0;
}