//UVa1587 - Box
//题目:给出6个矩形的长和宽,判断它们能否构成长方体的六个面
//6/3=2 个相同的面 WA,no more data in
#include <stdio.h>
#include<algorithm>
using namespace std;
int x[6],y[6],z[6];
bool right(void){
sort(z,z+6);
for(int i=0; i<6; i+=2) if(z[i] != z[i+1])return false;
return true;
}
int main(){
while(scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3],&x[4],&y[4],&x[5],&y[5]) == 12){
int is = 0;
for(int i = 0; i < 6; i++) {
if(x[i] < y[i]) swap(x[i], y[i]);
else if(x[i] == y[i])is++;
z[i]= x[i]*y[i]+2*1314;//纯C写法,用z[i]构造加密
}
if(!is)printf("%s\n", right() ? "POSSIBLE" : "IMPOSSIBLE");
else if(is >= 2)printf("IMPOSSIBLE\n");
}
return 0;
}
转载于:https://www.cnblogs.com/gwj1314/p/9444951.html