HDU 5655 四边形判断

Posted 半根毛线code

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 5655 四边形判断相关的知识,希望对你有一定的参考价值。

CA Loves Stick

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 563    Accepted Submission(s): 202


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
 
题意: 输入四边长 a,b,c,d判断能否组成四边形
题解: 1.根据边长的范围要考虑0
          2.四边形判断条件:升序排列后 最大边小于另外三边之和
          3.根据边长的范围:a[0]>a[3]-a[2]-a[1] (加法处理会爆数据范围 应当移项 减法处理)
 
 1 #include<iostream>
 2 #include<cstring>
 3 #include<cstdio>
 4 #include<map>
 5 #include<queue>
 6 #include<stack>
 7 #include<algorithm> 
 8 #define ll __int64
 9 #define mod 1 
10 #define PI acos(-1.0)
11 using namespace std;
12 ll a[5];
13 int t;
14 int main()
15 { 
16      scanf("%d",&t);
17      for(int i=1;i<=t;i++)
18 {
19     scanf("%I64d %I64d %I64d %I64d",&a[0],&a[1],&a[2],&a[3]);
20     sort(a,a+4);
21     //cout<<a[0]<<a[1]<<a[2]<<a[3]<<endl;
22     if(a[0]==0||a[1]==0||a[2]==0||a[3]==0)
23     cout<<"No"<<endl;
24     else
25     {
26     if(a[0]>a[3]-a[2]-a[1])
27      cout<<"Yes"<<endl;
28      else
29      cout<<"No"<<endl;
30     }
31 }
32     return 0;
33 }

 

以上是关于HDU 5655 四边形判断的主要内容,如果未能解决你的问题,请参考以下文章

hdu 5655 CA Loves Stick

hdu-5655 CA Loves Stick(水题)

HDU 2108 Shape of HDU (判断是不是凸多边形 叉乘)

hdu 2108 Shape of HDU 判断是否为凸多边形

hdu 1756(判断点是否在多边形中)

Cupid's Arrow---hdu1756(判断点与多边形的位置关系 模板)