Codeforces Round #313 Gerald is into Art (枚举)
来源:互联网 发布:老年人意外伤害数据 编辑:程序博客网 时间:2024/06/06 00:45
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
That's how we can place the pictures in the first test:
And that's how we can do it in the third one.
解析:枚举2个矩形的所有排列情况,进行判断即可。
代码:
#include<cstdio>#include<algorithm>using namespace std;int a[10],b[10];int main(){ scanf("%d%d%d%d%d%d",&a[1],&b[1],&a[2],&b[2],&a[3],&b[3]); if(a[1]*b[1]<a[2]*b[2]+a[3]*b[3]) {printf("NO\n");return 0;} if((a[1]>=max(a[2],a[3]) && b[1]>=b[2]+b[3]) || (a[1]>=max(a[2],b[3]) && b[1]>=b[2]+a[3]) || (a[1]>=max(b[2],a[3]) && b[1]>=a[2]+b[3]) || (a[1]>=max(b[2],b[3]) && b[1]>=a[2]+a[3]) || (b[1]>=max(a[2],a[3]) && a[1]>=b[2]+b[3]) || (b[1]>=max(a[2],b[3]) && a[1]>=b[2]+a[3]) || (b[1]>=max(b[2],a[3]) && a[1]>=a[2]+b[3]) || (b[1]>=max(b[2],b[3]) && a[1]>=a[2]+a[3]) )printf("YES\n"); else printf("NO\n"); return 0;}
- Codeforces Round #313 Gerald is into Art (枚举)
- Codeforces Round #313 (Div. 2) B. Gerald is into Art
- Codeforces Round #313 (Div. 2)-B. Gerald is into Art
- Codeforces Round #313 B. Gerald is into Art(简单题)
- CodeForces#313 B. Gerald is into Art
- 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)
- Codeforces Round #313 (Div. 2) Problem B. Gerald is into Art
- Codeforces 560B Gerald is into Art
- CodeForces 560B Gerald is into Art
- CodeForces 560B Gerald is into Art
- CodeForces - 560B Gerald is into Art
- Gerald is into Art
- Gerald is into Art(CF)
- CF560B:Gerald is into Art(思维)
- B. Gerald is into Art
- B. Gerald is into Art
- Codeforces 560B Gerald is into Art 放矩形
- Codeforces 560B Gerald is into Art(构造性算法)
- 黑马程序员——ios学习笔记 OC self&异常
- 利用外网主机穿透本地网络防火墙
- 桶排序
- Windows Sockets 网络编程——第四章 网络应用程序工作机制
- Hibernate工作原理及为什么要用?
- Codeforces Round #313 Gerald is into Art (枚举)
- B1010一元多项式求导 (25)
- JQuery获取复选框checkbox的值
- linux给命令取别名和为某些操作设置快捷键
- 关于就业指导和职业规划
- 表单前端验证+ajax异步请求
- An event-driven communication c# program
- Android:Toast 弹出信息框
- CF_37A_Towers