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分的地方卡了半天最后发现一个局部变量被我手抖写到全局去了,,, 心碎*∞ 没什么好解释的,其实只要写完表达式求值(带函数和变量的),然后处理一 ...
随机推荐
- 升级MySQL 5.7版本遇到的一些小问题(转)
在5.6版本服务器做备份 /usr/local/mysql/bin/mysqldump -S /tmp/mysql3306.sock -A -p --set-gtid-purged=OFF > ...
- 使用PowerShell创建Azure Storage的SAS Token访问Azure Blob文件
Azure的存储包含Storage Account.Container.Blob等具体的关系如下: 我们常用的blob存储,存放在Storage Account的Container里面. 目前有三种方 ...
- 2008上交:Day of Week
题目描述: We now use the Gregorian style of dating in Russia. The leap years are years with number divis ...
- HDOJ1025(最长上升子序列)
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65 ...
- n文件的上传和下载,struts2和springmvc
首先,struts2的上传下载的配置 因为struts2是配置的上传的拦截器,很简单的步揍就可以上传, 首先是配置struts的action映射 <!-- 4. 修改上传文件的最大大小为30M ...
- Springboot监控之一:SpringBoot四大神器之Actuator之2--spring boot健康检查对Redis的连接检查的调整
因为项目里面用到了redis集群,但并不是用spring boot的配置方式,启动后项目健康检查老是检查redis的时候状态为down,导致注册到eureka后项目状态也是down.问下能不能设置sp ...
- Golang Channel用法简编
转自:http://tonybai.com/2014/09/29/a-channel-compendium-for-golang/ 在进入正式内容前,我这里先顺便转发一则消息,那就是Golang 1. ...
- 如何更新node和npm版本
更新npm ---> npm undate -g 更新node ---> npm install -g -n n latest
- struts2 json返回试验
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-/ ...
- SpringMVC RESTful中文乱码
开发中常遇到各种中文乱码很少心烦,这里总结了各种中文乱码https://www.cnblogs.com/lwx521/p/9856186.html 下面以SpringMVC遇到的中文乱码为例详解 首先 ...