【Gym 100971G】Repair

2020-06-02 15:31:16 浏览数 (2)

BUPT 2017 summer training (for 16) #1B

题意

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 (a_1) × b_1 and (a_2) × (b_2) from it. All cuts must be parallel to the sides of the initial sheet. Determine if he can do it.

题解

把所有情况都找一遍,也就是要交换长和宽。

代码

代码语言:javascript复制
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    long long a,b,c,d,e,f;
    scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
    bool t=false;
    for(int i=0;i<2;  i){
        for(int j=0;j<2;  j){
            for(int k=0;k<2;  k){
                t|=(max(c,e)<=a&&d f<=b);
                swap(c,d);
            }
            swap(e,f);
        }
        swap(a,b);
    }
    printf("%s",t?"YES":"NO");
    return 0;
}

0 人点赞