链接: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;
}