您的位置:首页 > 其它

hdu 5655 CA Loves Stick(简单题)(Bestcoder #78 1001)

2016-04-03 12:26 459 查看
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)

Total Submission(s): 416 Accepted Submission(s): 153



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

2
1 1 1 1
1 1 9 2


Sample Output

Yes
No


Source

BestCoder Round #78 (div.2)

Recommend

wange2014

题目大意:

给四根木棍长度,问能否拼成一个四边形

解题思路:

参见http://ziyuan.wmw.cn/WLKT/LWMWMZ/RJB/classonline/content0409/2b/2b58001/html/241hb_12.htm证明的很清楚,有中学生的风格

所以最小的三条边加起来大于最大边就可以,反之不可以,但是小心高精度,unsigned long long 可以解决两个longlong数加的问题,所以改写为a[0]+a[2]>a[3]-a[1]即可,但是注意有长为0的木棍!!神棍啊!有一个0就输出no即可。

<pre name="code" class="cpp">#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<stack>
#define ll unsigned long long
#define INF 0x3f3f3f3f
#define C(a) memset(a,0,sizeof a)
#define C_1(a) memset(a,-1,sizeof a)
#define C_i(a) memset(a,0x3f,sizeof a)
#define F(i,n) for(int i=0;i<n;i++)
#define F(n) for(int i=0;i<n;i++)
#define F_1(n) for(int i=n;i>0;i--)
#define S(a) scanf("%d",&a);
#define S2(a,b) scanf("%d%d",&a,&b);
#define SL(a) cin>>a;
#define SD(a) scanf("%lf",&a);
#define P(a) printf("%d\n",a);
#define PL(a) printf("%I64d\n",a);
#define PD(a)printf("%lf\n",a);
#define rush() int t;scanf("%d",&t);while(t--)
using namespace std;
int main()
{
ll a[4];
rush()
{
SL(a[0])SL(a[1])SL(a[2])SL(a[3]);
sort(a, a + 4);
if (!a[0] || !a[1] || !a[2] || !a[3])printf("No\n");
else if (a[3] - a[1] < a[2]+a[0])printf("Yes\n");
else printf("No\n");
}
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: