zoukankan      html  css  js  c++  java
  • UVa1587 Box

    #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;
    }

  • 相关阅读:
    nginx解决前端跨域配置
    oracle 空表处理
    (转)Oracle修改表空间为自动扩展
    使用silverlight自定义控件时“给定关键字不在字典中”
    arcengine note:
    Jquery CSS 操作
    Jquery Easy-UI 树形菜单的运用
    Easy-UI data-options总结
    数据库 存储过程初探
    ASP.NET 日志的记录(登录日志和异常日志和操作日志)
  • 原文地址:https://www.cnblogs.com/danny1221/p/4601451.html
Copyright © 2011-2022 走看看