codeforces-gym101630-B【Box】

题目:

Bella is working in a factory that produces boxes. All boxes are in a shape of rectangular parallelepipeds.
A net of the corresponding parallelepiped is cut out of a flat rectangular piece of cardboard of size w × h.
This net is a polygon with sides parallel to the sides of the rectangle of the cardboard. The net is bent
along several lines and is connected along the edges of the resulting parallelepiped to form a box. The
net is bent only along the edges of the resulting box.
The third example
The first example
Bella is a software developer and her task is to check whether it is possible to make a box of size a × b × c
out of a cardboard of size w × h. Bella did write a program and boxes are being produced. Can you do
the same?
Input
The first line contains three integers a, b, and c — the dimensions of the box.
The second line contains two integers w and h — the width and the height of the cardboard.
All integers are positive and do not exceed 10 8 .
Output
Print “Yes” if it is possible to cut a box a × b × c out of a cardboard of size w × h. Print “No” otherwise.

input

1 2 3
5 6
1 2 3
5 5
1 1 1
10 2

ouput

Yes
No
Yes

codeforces-gym101630-B【Box】_第1张图片
题意:
给出一个长方体或者立方体的三边长和一张纸的长和宽,问能不能通过裁剪这张纸,组成一个想要的长方体。

题解:
给出的11种组成的方式中,长和宽只有三种情况,34,43,52,通过把这三种方式画出来可以得到三种方式的长和宽分别为
2
a+b ,2a+2c
a+b+c,2a+b+c
3
a+b+c,b+c
所以暴力这三条边,找是否比纸张的长和宽小就可以了

代码:

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define PI acos(-1)
const int mod=1e9+7;
const int M=1e5 + 10;
int check(ll a,ll b,ll c,ll w,ll h)
{
    if(3*a+b+c <= w && b+c <= h || 3*a+b+c <= h && b+c <= w)
        return 1;
    if(2*a+b <= w && 2*a+2*c <=h || 2*a+b <=h && 2*a+2*c <= w)
        return 1;
    if(a+b+c <= w && 2*a+b+c <=h || a+b+c <=h && 2*a+b+c <= w)
        return 1;
    return 0;
}
int main()
{
    ll a,b,c,n,m;
    while(cin>>a>>b>>c>>n>>m){
        if(a==b&&b==c){
            if(m>=a*3&&n>=a*4||m>=a*4&&n>=a*3||m>=a*2&&n>=a*5||m>=a*5&&n>=2*a)
                cout<<"Yes"<

你可能感兴趣的:(ACM)