HDU5655 CA Loves Stick (BC)

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.
1T1000, 0a,b,c,d2631
 

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
 

Source

題意:給出四條邊長,求是否可能組成一個四邊形。
分析:就只要判斷最長的那條邊是不是比其他三條邊之和大就行了;主要是數據坑啊!!

<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>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章