码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 5655 四边形判断

时间:2016-04-03 21:55:28      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

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 四边形判断

标签:

原文地址:http://www.cnblogs.com/hsd-/p/5350549.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!