CA Loves Stick
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1 Accepted Submission(s): 0
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≤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
Sample Output
Source
BestCoder Round #78 (div.2)
题意:给出四条边长,求是否可能组成一个四边形。
分析:就只要判断最长的那条边是不是比其他三条边之和大就行了;主要是数据坑啊!!
<span style="font-size:18px;">#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
#define ll long long
#define CL(a,b) memset(a,b,sizeof(a))
#define lson (i<<1)
#define rson ((i<<1)|1)
#define MAXN 100010
int main()
{
ll n;
ll a[4];
cin>>n;
while(n--)
{
cin>>a[0]>>a[1]>>a[2]>>a[3];
sort(a, a+4);
if(a[0] == 0){cout<<"No"<<endl; continue;}
if(a[2]>(a[3]-a[0]) || a[2]>((a[3]-a[0])-a[1]))
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}</span>