UVa1587 Box
2015-06-26 08:39
435 查看
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
set<int> s; // 12个数字中不能出现3个以上不同的值,最多只有三种值:长、宽、高
int face[6];
int i = 0, w, h;
while (cin >> w >> h)
{
if (s.size() <= 3)
{
s.insert(w);
s.insert(h);
if (w > h)
face[i] = (h << 16) | w; // 充分利用条件 1 <= w,h <= 10000
else
face[i] = (w << 16) | h;
}
if (++i == 6)
{
if (s.size() <= 3)
{
sort(face, face+6);
for (i = 0; i < 6; i += 2)
{ // 判断是否存在3对相等的面
if (face[i] != face[i+1])
break;
}
if (i == 6)
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
}
else
{
cout << "IMPOSSIBLE" << endl;
}
i = 0;
s.clear();
}
}
return 0;
}
#include <algorithm>
#include <set>
using namespace std;
int main()
{
set<int> s; // 12个数字中不能出现3个以上不同的值,最多只有三种值:长、宽、高
int face[6];
int i = 0, w, h;
while (cin >> w >> h)
{
if (s.size() <= 3)
{
s.insert(w);
s.insert(h);
if (w > h)
face[i] = (h << 16) | w; // 充分利用条件 1 <= w,h <= 10000
else
face[i] = (w << 16) | h;
}
if (++i == 6)
{
if (s.size() <= 3)
{
sort(face, face+6);
for (i = 0; i < 6; i += 2)
{ // 判断是否存在3对相等的面
if (face[i] != face[i+1])
break;
}
if (i == 6)
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
}
else
{
cout << "IMPOSSIBLE" << endl;
}
i = 0;
s.clear();
}
}
return 0;
}
相关文章推荐
- 基于squashfs的gluebi文件系统开发
- 关于ES、PES、PS以及TS码流
- ViewFlipper
- More Effective C++ 条款6 区别 increment/decrement 操作符的前置(prefix)和后置(postfix)形式
- 简明 Git 命令速查表
- APP主流UI框架结构
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量
- 关于u-boot中gd变量