Repair 暴力
Description
Statements
Alex is repairing his country house. He has a rectangular metal sheet of size a × b. He has to cut two rectangular sheets of sizes a1 × b1and a2 × b2 from it. All cuts must be parallel to the sides of the initial sheet. Determine if he can do it.
Input
The first line contains two space-separated integers a and b (1 ≤ a, b ≤ 109) — the sizes of the initial sheet.
The second line contains two space-separated integers a1 and b1 (1 ≤ a1, b1 ≤ 109) — the sizes of the first sheet to cut out.
The third line contains two space-separated integers a2 and b2 (1 ≤ a2, b2 ≤ 109) — the sizes of the second sheet to cut out.
Output
Output «YES» (without quotes), if it's possible to cut two described sheets from the initial sheet, or «NO» (without quotes), if it's not possible.
Sample Input
12 20
14 7
5 6
YES
12 20
11 9
20 7
NO 枚举那两个小长方形的形状,要么躺着,要么倒着,
然后位置关系也有2中,上下或者左右。一共8种情况
枚举有技巧,不用全部写if。考怒写循环。
固定1,枚举2的两种形状,枚举2的位置关系。
固定2,枚举1的两种形状,枚举1的位置关系。
这样做的话,没法做到同时转换1和转换2.
那么考虑转换大长方形再来一次,就能考怒完全部。
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
struct data {
int row, col;
} a[];
bool check(int torow, int tocol) {
if (torow <= a[].row && tocol <= a[].col) return true;
else return false;
}
void work() {
for (int i = ; i <= ; ++i) {
cin >> a[i].row >> a[i].col;
}
bool flag = false;
for (int i = ; i <= && !flag; ++i) {
if (check(max(a[].row, a[].row), a[].col + a[].col)) {
flag = true;
}
if (check(a[].row + a[].row, max(a[].col, a[].col))) {
flag = true;
}
swap(a[].row, a[].col);
}
// cout << a[3].row << " " << a[3].col << endl;
for (int i = ; i <= && !flag; ++i) {
if (check(max(a[].row, a[].row), a[].col + a[].col)) {
flag = true;
}
if (check(a[].row + a[].row, max(a[].col, a[].col))) {
flag = true;
}
swap(a[].row, a[].col);
}
swap(a[].row, a[].col);
for (int i = ; i <= && !flag; ++i) {
if (check(max(a[].row, a[].row), a[].col + a[].col)) {
flag = true;
}
if (check(a[].row + a[].row, max(a[].col, a[].col))) {
flag = true;
}
swap(a[].row, a[].col);
}
// cout << a[3].row << " " << a[3].col << endl;
for (int i = ; i <= && !flag; ++i) {
if (check(max(a[].row, a[].row), a[].col + a[].col)) {
flag = true;
}
if (check(a[].row + a[].row, max(a[].col, a[].col))) {
flag = true;
}
swap(a[].row, a[].col);
} if (flag) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}
Repair 暴力的更多相关文章
- CodeForces 730G Car Repair Shop (暴力)
题意:给定 n 个工作的最好开始时间,和持续时间,现在有两种方法,第一种,如果当前的工作能够恰好在最好时间开始,那么就开始,第二种,如果不能,那么就从前找最小的时间点,来完成. 析:直接暴力,每次都先 ...
- 通用高效的数据修复方法:Row level repair
导读:随着大数据的进一步发展,NoSQL 数据库系统迅速发展并得到了广泛的应用.其中,Apache Cassandra 是最广泛使用的数据库之一.对于 Cassandra 的优化是大家研究的热点,而 ...
- zone.js - 暴力之美
在ng2的开发过程中,Angular团队为我们带来了一个新的库 – zone.js.zone.js的设计灵感来源于Dart语言,它描述JavaScript执行过程的上下文,可以在异步任务之间进行持久性 ...
- [bzoj3123][sdoi2013森林] (树上主席树+lca+并查集启发式合并+暴力重构森林)
Description Input 第一行包含一个正整数testcase,表示当前测试数据的测试点编号.保证1≤testcase≤20. 第二行包含三个整数N,M,T,分别表示节点数.初始边数.操作数 ...
- HDU 5944 Fxx and string(暴力/枚举)
传送门 Fxx and string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Othe ...
- 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)
湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...
- fragment+viepager 的简单暴力的切换方式
这里是自定义了一个方法来获取viewpager private static ViewPager viewPager; public static ViewPager getMyViewPager() ...
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- uoj98未来程序改 纯暴力不要想了
暴力模拟A了,数据还是良(shui)心(shui)的 90分的地方卡了半天最后发现一个局部变量被我手抖写到全局去了,,, 心碎*∞ 没什么好解释的,其实只要写完表达式求值(带函数和变量的),然后处理一 ...
随机推荐
- 给.sh文件添加可执行权限
有时我们运行.sh文件时会发现没有权限,具体解决方案如下 第一种:bash+执行文件 第二种:chmod命令 如果给所有人添加可执行权限:chmod a+x 文件名:如果给文件所有者添加可执行权限:c ...
- python操作sql server2008 pyodbc
使用Python通过PyODBC连接数据的注意事项 今天使者用PyODBC连接数据库,试了很久才出来,现把一些心得体会和大家分享! 一.PyODBC的下载地址: http://code.google. ...
- DNS服务器的配置与管理
安装DNS服务器: 在"服务器管理器"-"角色"-"添加角色"中安装DNS服务器. 选择DNS服务器 点下一步安装,然后安装 固定服务器IP ...
- ssh功能模块——paramiko
参考官网文档:http://docs.paramiko.org/
- 关于startactivity初始化activity的过程以及activity和window以及view的关系
activity 构造一个实现了window的phonewindow,获得viewroot,然后往里面加入view 当发生事件的时候,如KEYDOWN,windowmanagerservice就接受到 ...
- [#413c] Fountains
http://codeforces.com/contest/799/problem/C 解题关键:树状数组取最大值,注意先搜索,后加入,此种情况可以取出最大值. 为什么可以取到最大值? 1.当分别用两 ...
- layui 文件上传加进度条
1.页面 <div class="layui-row layui-col-space5"> <div class="layui-form-item&qu ...
- [原创]SQL表值函数:返回自定义时间段的日期数据
跟以往类似,我依旧介绍一个我日常开发遇到的知识点,谨此记录一下,也希望能帮助到一些朋友. 这次我要介绍的是通过SQL函数返回你输入的两个时间点内的日期数据. 效果图如下: 执行函数:SELECT * ...
- 项目一:第六天 WebService写接口 和CXF框架
1 课程计划 1. webService入门(了解) 2. 基于jdk1.7开发webservice服务(了解) 3. Apache CXF框架入门(掌握) 4. 基于CXF框架搭建CRM系统(掌握) ...
- 树莓派 Learning 002 装机后的必要操作 --- 01 解决上网问题
树莓派 装机后的必要操作 - 解决上网问题 我的树莓派型号:Raspberry Pi 2 Model B V1.1 装机系统:NOOBS v1.9.2 树莓派 装机后的必要操作 解决上网问题 解决上网 ...