其他分享
首页 > 其他分享> > ABC 223 | E - Placing Rectangles

ABC 223 | E - Placing Rectangles

作者:互联网

题目描述

给定\(X, Y, A, B, C\),问能否在\(0 \le x \le X, 0 \le y \le Y\)的范围中不相重叠地放置面积为\(A, B, C\)的三个矩形。

数据范围

解题思路

bool solve3(ll x, ll y, ll a, ll b, ll c)
{
    for(int i = 0; i < 2; i ++){
        for(int j = 0; j < 3; j ++){
            ll len = (a - 1) / x + 1;
            if(len < y && solve2(x, y - len, b, c)){
                return true;
            }
            swap(a, b);
            swap(b, c);
        }
        swap(x, y);
    }
    return false;
}

代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

ll x, y, a, b, c;

bool solve2(ll x, ll y, ll a, ll b)
{
    for(int i = 0; i < 2; i ++){
        ll len = (a - 1) / x + 1;
        if(len < y && x * (y - len) >= b) return true;
        swap(x, y);
    }
    return false;
}

bool solve3(ll x, ll y, ll a, ll b, ll c)
{
    for(int i = 0; i < 2; i ++){
        for(int j = 0; j < 3; j ++){
            ll len = (a - 1) / x + 1;
            if(len < y && solve2(x, y - len, b, c)){
                return true;
            }
            swap(a, b);
            swap(b, c);
        }
        swap(x, y);
    }
    return false;
}

int main()
{
    scanf("%lld%lld%lld%lld%lld", &x, &y, &a, &b, &c);
    if(solve3(x, y, a, b, c)) puts("Yes");
    else puts("No");
    return 0;
}

标签:ABC,return,ll,Placing,len,le,swap,矩形,Rectangles
来源: https://www.cnblogs.com/bxhbxh/p/16382140.html