Box UVA - 1587

思路:一个长方形六个面之间两两相等,所以在确认了六个面两两相等之后,只需要通过3个面就可以确定是否能形成一个长方形,通过按升序排好的长方体进行优化就可以找到规律来。

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef struct node{
	int h,w;
}nod;
nod node[7];
bool map(nod x,nod y)
{
	if(x.w!=y.w)
	return x.w<y.w;
	else return x.h<y.h;
}
bool fun()
{
	if(node[1].w!=node[2].w||node[1].h!=node[2].h)return false;
	else if(node[3].w!=node[4].w||node[3].h!=node[4].h)return false;
	else if(node[5].w!=node[6].w||node[5].h!=node[6].h)return false;
	else if(node[1].w!=node[3].w||node[5].w!=node[1].h||node[3].h!=node[5].h) return false;
	else return true;
}
int main()
{
	int x,y;
    while(1)
    {
    	for(int i=1;i<=6;i++)
    	{
    		if(scanf("%d%d",&x,&y)!=2)return 0;
    		if(x>y){node[i].h=x;node[i].w=y;
			}else {node[i].h=y;node[i].w=x;
			}
		}
		sort(node+1,node+7,map);
		bool f=fun();
		if(f)printf("POSSIBLE\n");
		else printf("IMPOSSIBLE\n");
	}
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值