HDU - 5655 CA Loves Stick
来源:互联网 发布:大专程序员 编辑:程序博客网 时间:2024/05/29 06:37
1.题面
http://acm.hdu.edu.cn/showproblem.php?pid=5655
2.题意
给你四个木棍的长度,问你这四根木棍能不能组成一个四边形。
3.思路
四边形成立的条件比较简单,就是任意三边之和大于第四边。
但是这道题目有两个坑。
一是输入的四条边中可能会出现长度为0的边。
二是四个数据都比较大,直接加减都容易爆long long。我的解决方案是使用unsighed long long,sort后判断a[0]+a[1] < a[2] + a[3]。
4.代码
/***************************************************************** > File Name: tmp.cpp > Author: Uncle_Sugar > Mail: uncle_sugar@qq.com > Created Time: 2016年04月02日 星期六 19时04分08秒*****************************************************************/# include <cstdio># include <cstring># include <cmath># include <cstdlib># include <climits># include <iostream># include <iomanip># include <set># include <map># include <vector># include <stack># include <queue># include <algorithm>using namespace std;const int debug = 1;const int size = 5000 + 10; const int INF = INT_MAX>>1;typedef unsigned long long ll;int main(){ std::ios::sync_with_stdio(false);cin.tie(0); int i,j; int T; cin >> T; while (T--){ ll r[4]; for (i=0;i<4;i++){ cin >> r[i]; } sort(r,r+4); if (r[0]>0&&r[0]+r[1]>r[3]-r[2]) cout << "Yes\n"; else cout << "No\n"; } return 0;}
0 0
- HDU 5655 CA Loves Stick
- HDU 5655 CA Loves Stick
- HDU - 5655 CA Loves Stick
- HDU 5655 CA Loves Stick
- hdu 5655 CA Loves Stick
- HDU 5655 CA Loves Stick
- HDU 5655 CA Loves Stick
- CA Loves Stick HDU
- CA Loves Stick HDU
- hdu 5655 CA Loves Stick【思维】
- HDU-5655 CA Loves Stick(Water) 判断
- 【HDU 5655】【水题】CA Loves Stick
- hdu 5655 CA Loves Stick(水题)
- HDU-5655 CA Loves Stick(数学)
- BestCoder Round #78 1001/ hdu 5655 CA Loves Stick
- HDU 5655 CA Loves Stick(思维题目)【bestcoder】
- 杭电5655 CA Loves Stick
- HDOJ 5655-CA Loves Stick【思维题】
- 八大排序算法之直接插入排序
- iOS 中UIAlertView 的简单使用
- JFrame实现无边框 及 实现拖动和Button关闭功能
- 采集侠的自动crontab脚本
- Android设计模式应用-桥接模式
- HDU - 5655 CA Loves Stick
- Bit manipulation
- Linux Shell笔记
- C#的数据类型简介
- 杭电2700
- JavaScript编写人机对战五子棋(二)
- 代码块的那点事
- 杭电2567
- angularJs小应用----计算购物金额-动态改变邮费