I Box

14 篇文章 0 订阅
9 篇文章 0 订阅

Box

链接:https://ac.nowcoder.com/acm/contest/7854/I
来源:牛客网
 

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.

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?

输入描述:

 

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 108.

输出描述:

Print “Yes” if it is possible to cut a box a × b × c out of a cardboard of size w × h. Print “No” otherwise.

示例1

输入

复制1 2 3 6 5

1 2 3
6 5

输出

复制Yes

Yes

示例2

输入

复制1 2 3 5 5

1 2 3
5 5

输出

复制No

No

示例3

输入

复制1 1 1 10 2

1 1 1
10 2

输出

复制Yes

Yes

说明

 

There are 11 different nets of a cube, ignoring rotations and mirror images.

备注:

Author: Georgiy Korneev

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll maxn=1e5+7;
ll n,a,b,c,m,l,r;
bool f1(int x,int y,int z)
{
    l=2*x+y*2;
    r=2*x+z;
    if(l>r)
        swap(l,r);
    if(l<=n&&r<=m)
        return true;
    else
        return false;
}
bool f2(int x,int y,int z)
{
    l=x+y*2+z;
    r=x+2*z;
    if(l>r)
        swap(l,r);
    if(l<=n&&r<=m)
        return true;
    else
        return false;
}
bool f3(int x,int y,int z)
{
    l=x*2+y+z;
    r=y+x+z;
    if(l>r)
        swap(l,r);
    if(l<=n&&r<=m)
        return true;
    else
        return false;
}
bool f4(int x,int y,int z)
{
    l=3*x+y+z;
    r=y+z;
    if(l>r)
        swap(l,r);
    if(l<=n&&r<=m)
        return true;
    else
        return false;
}
bool f5(int x,int y,int z)
{
    l=x+y*2+z;
    r=x+y+z;
    if(l>r)
        swap(l,r);
    if(l<=n&&r<=m)
        return true;
    else
        return false;
}
bool f6(int x,int y,int z)
{
    l=x*2+y+z;
    r=y+z*2;
    if(l>r)
        swap(l,r);
    if(l<=n&&r<=m)
        return true;
    else
        return false;
}
bool solve()
{
    if(f1(a,b,c))
        return true;
    if(f1(a,c,b))
        return true;
    if(f1(b,a,c))
        return true;
    if(f1(b,c,a))
        return true;
    if(f1(c,b,a))
        return true;
    if(f1(c,a,b))
        return true;
    if(f2(a,b,c))
        return true;
    if(f2(a,c,b))
        return true;
    if(f2(b,a,c))
        return true;
    if(f2(b,c,a))
        return true;
    if(f2(c,b,a))
        return true;
    if(f2(c,a,b))
        return true;
    if(f3(a,b,c))
        return true;
    if(f3(a,c,b))
        return true;
    if(f3(b,a,c))
        return true;
    if(f3(b,c,a))
        return true;
    if(f3(c,b,a))
        return true;
    if(f3(c,a,b))
        return true;
    if(f4(a,b,c))
        return true;
    if(f4(a,c,b))
        return true;
    if(f4(b,a,c))
        return true;
    if(f4(b,c,a))
        return true;
    if(f4(c,b,a))
        return true;
    if(f4(c,a,b))
        return true;
    if(f5(a,b,c))
        return true;
    if(f5(a,c,b))
        return true;
    if(f5(b,a,c))
        return true;
    if(f5(b,c,a))
        return true;
    if(f5(c,b,a))
        return true;
    if(f5(c,a,b))
        return true;
    if(f6(a,b,c))
        return true;
    if(f6(a,c,b))
        return true;
    if(f6(b,a,c))
        return true;
    if(f6(b,c,a))
        return true;
    if(f6(c,b,a))
        return true;
    if(f6(c,a,b))
        return true;
    return false;
}
int main()
{
    cin>>a>>b>>c;
    cin>>n>>m;
    if(n>m)
        swap(n,m);
    if(solve())
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值