Gerald is into Art
Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an a1 × b1 rectangle, the paintings have shape of a a2 × b2 and a3 × b3 rectangles.
Since the paintings are painted in the style of abstract art, it does not matter exactly how they will be rotated, but still, one side of both the board, and each of the paintings must be parallel to the floor. The paintings can touch each other and the edges of the board, but can not overlap or go beyond the edge of the board. Gerald asks whether it is possible to place the paintings on the board, or is the board he bought not large enough?
The first line contains two space-separated numbers a1 and b1 — the sides of the board. Next two lines contain numbers a2, b2, a3 andb3 — the sides of the paintings. All numbers ai, bi in the input are integers and fit into the range from 1 to 1000.
If the paintings can be placed on the wall, print "YES" (without the quotes), and if they cannot, print "NO" (without the quotes).
3 21 32 1
YES
5 53 33 3
NO
4 22 31 2
YES 地址:http://codeforces.com/contest/560/problem/B思路:题意很简单就是把2个长方形放在一个大的长方形的里,看是否能成功。 刚开始,在想的时候,忘了只有个2个长方形,感觉好难。最后再看了下是2个。。 于是就简单了,但是也没有想到什么好办法。直接考虑所以的情况,应该是8种。 最后就AC了,百度了下好像大家都是这么做的,至于多个长方形的情况还有待考虑,还有别人的代码细节写的比我简单些。
#include <cstdio> using namespace std; int main(){ int a1, b1; int a2, b2; int a3, b3; while(scanf("%d%d", &a1, &b1) != EOF){ scanf("%d%d", &a2, &b2); scanf("%d%d", &a3, &b3); ; if((a2 * b2 + a3 * b3) > (a1 * b1)){ flag = ; } else{ if((a2 + a3) <= a1 && b2 <= b1 && b3 <= b1){ } else if((a2 + b3) <= a1 && b2 <= b1 && a3 <= b1){ } else if((a2 <= a1 && a3 <= a1 && (b2 + b3) <= b1)){ } else if(a2 <= a1 && b3 <= a1 && (b2 + a3) <= b1){ } else if((b2 + a3) <= a1 && a2 <= b1 && b3 <= b1){ } else if((b2 + b3) <= a1 && a2 <= b1 && a3 <= b1){ } else if(b2 <= a1 && a3 <= a1 && (a2 + b3) <= b1){ } else if(b2 <= a1 && b3 <= a1 && (a2 + a3) <= b1){ } else{ flag = ; } } == flag){ printf("NO\n"); }else{ printf("YES\n"); } } ; }
2015-07-26 18:15:47
Gerald is into Art的更多相关文章
- Codeforces Round #313 (Div. 2)B.B. Gerald is into Art
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/ ...
- CodeForces 560B Gerald is into Art
Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #313 (Div. 2) B. Gerald is into Art 水题
B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560 ...
- B. Gerald is into Art
B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)
[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...
- Codeforces Round #313 B. Gerald is into Art(简单题)
B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 【45.65%】【codeforces 560B】Gerald is into Art
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 567A Gerald is into Art
http://codeforces.com/problemset/problem/567/A A. Lineland Mail time limit per test 3 seconds memory ...
- Codeforces Round #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings
A题,超级大水题,根据有没有1输出-1和1就行了.我沙茶,把%d写成了%n. B题,也水,两个矩形的长和宽分别加一下,剩下的两个取大的那个,看看是否框得下. C题,其实也很简单,题目保证了小三角形是正 ...
随机推荐
- Volley 实现原理图
1.启动requestQueue 2. 添加请求 3. 启动cacheDispatcher 4.启动networkDispatcher 5. 数据分发
- Android的学习第六章(布局二--RelativeLayout)
今天我们来说一下Android布局中的Relativelayout布局(相对布局) 根据英译过来意思是相对布局,很容易理解,这一样布局使用的是元素与元素之间的微调做到布局的 含义:通过元素与元素之间的 ...
- Fragment全解析系列(二):正确的使用姿势
作为一个稳定的app,从后台且回到前台,一定会在任何情况都能恢复到离开前的页面,并且保证数据的完整性. 如果你没看过本系列的第一篇,为了方便后面文章的介绍,先规定一个"术语",安卓 ...
- webstorm 配置scss的问题
第一种方法(ruby方法) 先安装ruby,在windows/system32目录下 1.先查询源是什么 gem sources 2.移除原有的源头 gem sources -r http://xxx ...
- Android4.0.3 USB OTG底层插入上报过程分析(1)
下面的两个宏是PM8058的MMP11(R15),MMP12(P15)管脚.#define EXT_CHG_VALID_MPP 10#define EXT_CHG_VALID_MPP_2 11 sta ...
- [OC] 理解Bitcode:一种中间代码
Tip:参考资料 理解Bitcode:一种中间代码 (内容从该博客摘录的.本随笔摘录些简要内容.) App Distribution Guide – App Thinning (iOS, watchO ...
- CentOS 7 最小化安装的无线网络配置
1.首先下载iw工具. yum -y install iw 2.获取无线网卡的名称 执行iw dev,假设获得名称为 wlp3s0(示例) 3.激活无线网络接口 执行ip link set wlp3s ...
- Sprint第三阶段(第三天12.11)
- Knockout 官网翻译
Knockout 新版应用开发教程之创建view models与监控属性 章节导航 最近抽出点时间研究MVVM,包括司徒正美的avalon,google的angular,以及Knockout,博客园T ...
- 扒一扒自从买了kindle后看的书
一.<性别战争> 讲述的是动物界各类动物的xxx(你懂的),以动物拟人化的口吻来进行问答,十分的生动形象,虽说和自己的生活没有多大联系,但是偶尔了解一下,也是意外的不错的感觉. 二.< ...