HDU5655
来源:互联网 发布:微博怎么设置个性域名 编辑:程序博客网 时间:2024/05/05 10:05
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≤2^63−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
Explanation
该题给我们四条线段的长度问是否能拿这四条线段构成一个四边形
我们考虑一个极限情况,当三条线段共线首尾连接时,第四条边无论多长都无法构成四边形,但在当连接后的三条边任意轻微改变其中两条边的夹角就存在一条边可以与其构成四边形了,那么第四条边则为最长边,且其长度满足小于其他三边之和
Code
#include <stdio.h>#include <algorithm>using namespace std;int main(){ int t; scanf("%d",&t); while(t--){ long long a[5]; scanf("%lld%lld%lld%lld",&a[0],&a[1],&a[2],&a[3]); sort(a,a+4); if(a[0]==0) printf("No\n"); //若存在长度为0的边则一定无法构成四边形 else{ if(a[3]-a[2]-a[1]<a[0]) printf("Yes\n"); else printf("No\n"); /*这里要注意数据超范围 1> 对三条边作和则会超出long long范围 2> 最大边减去另外三条边也会超出long long范围 */ } } return 0;}
- HDU5655
- BC78,hdu5655,5656。%%%%CA娘
- HDU5655 CA Loves Stick (BC)
- hdu5655 CA Loves Stick JAVA大数
- hdu5655-BestCoder Round #78 (div.2)
- 【计算机视觉】【神经网络与深度学习】深度学习在图像超分辨率重建中的应用
- 目录——Web第三阶段:Javascript
- es6新特性之generator
- Codeforce 868 C Qualification Rounds (计数原理)
- 多媒体编辑模块架构设计
- HDU5655
- 达内课程-高级流/操作流BufferedOutputStream/BufferedInputStream
- leetcode013-Maximal Square(dp)
- Django的国际化
- 对象构造和初始化
- hexo yilia主题添加文章访问量统计
- intellij tab键改为4个空格
- Java【集合系列】-08-List总结(LinkedList, ArrayList等使用场景和性能分析)
- 【计算机视觉】分辨率与超分辨率图像重建