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
Sample Output
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即可。
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"); } }
相关文章推荐
- Linux kernel模块管理相关详解
- 常见问题
- 【FFMPEG】谈谈RTP传输中的负载类型和时间戳
- vmware tools安装
- 仿百度壁纸客户端(三)——首页单向,双向事件冲突处理,壁纸列表的实现
- 大数据工程师:大数据的java基础 第八周
- 仿百度壁纸客户端(三)——首页单向,双向事件冲突处理,壁纸列表的实现
- Android课程---单选框与复选框的实现
- c++中动态尾随内存的技巧和定位new
- SAS学习笔记:创建图表
- create samba server
- jquery中attr和prop的区别
- 理解Cookie和Session机制
- Exception starting filter Struts2
- 开源的相关记录
- Android编译详解之lunch命令
- webdriver中Xpath当前节点寻找父节点下的字节点
- 工厂模式和策略模式的区别
- JAVA反射机制
- HashMap 原理和源码分析