题目大意:给出一块木板的长和宽和两幅画的长和宽,问是否能把两幅画同时放在木板里。
解题思路:每幅画的任意一边之和要小于木板的长(或宽),且每幅画的另外一边要同时小于木板的宽(或长)。说起来有些拗口,其实很好理解。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctype.h>
using namespace std;
int shape[2][2];
int main() {
int a, b;
scanf("%d%d", &a, &b);
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
scanf("%d", &shape[i][j]);
int tag = 0;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++) {
if (shape[0][i] + shape[1][j] <= a) {
if (shape[0][1-i] <= b && shape[1][1-j] <= b)
tag = 1;
}
if (shape[0][i] + shape[1][j] <=b) {
if (shape[0][1-i] <= a && shape[1][1-j] <= a)
tag = 1;
}
}
if (tag) printf("YES\n");
else printf("NO\n");
return 0;
}