• EOJ1014 BOX


    poj 2160 http://poj.org/problem?id=2160

    eoj 1014 http://www.acm.cs.ecnu.edu.cn/problem.php?problemid=1014

    题意:给定6个矩形,判断能否组成一个盒子。

    简单的说一下思想:
    假设这个Box有6个面,那么长宽高分别是a、b、c。
    那么就有3个面的关系如下(一共六个面,但是相对的面相等):
    a * b
    a * c
    b * c
    这里假设 a >= b >= c
    我的想法是先输入,再按长边排序。
    如Sample 得到的就是
    2584 1345 
    2584 1345 //与上面的对称
    2584 683
    2584 683  //与上面的对称
    1345 683
    1345 683  //与上面的对称
    那么就判断这六条边的关系就OK了。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <string>
     5 #include <algorithm>
     6 using namespace std;
     7 struct Node
     8 {
     9     int x, y;
    10 }a[7];
    11 
    12 bool cmp(const Node &a, const Node &b)
    13 {
    14     if (a.x != b.x)
    15         return a.x > b.x;
    16     else
    17         return a.y > b.y;
    18 }
    19 
    20 int main()
    21 {
    22     int x, y;
    23     for (int i = 0; i < 6; i++)
    24     {
    25         cin >> x >> y;
    26         a[i].x = max(x, y);
    27         a[i].y = min(x, y);
    28     }
    29     sort(a, a + 6, cmp);
    30     int flag = 0;
    31     //for (int i = 0; i < 6; i++)
    32         //cout << a[i].x << ' ' << a[i].y<< endl;
    33      if (a[0].x == a[1].x && a[1].x == a[2].x && a[2].x == a[3].x)
    34     {
    35         if (a[0].y == a[1].y && a[1].y == a[4].x && a[4].x == a[5].x)
    36         {
    37             if (a[2].y == a[3].y && a[3].y == a[4].y && a[4].y == a[5].y)
    38                 flag = 1;
    39         }
    40     }
    41     if (flag)
    42         cout << "POSSIBLE" << endl;
    43        else
    44            cout << "IMPOSSIBLE" << endl;
    45     return 0;
    46 }
    View Code
  • 相关阅读:
    UVALive
    hdu 3869 Color the Simple Cycle (kmp+polya计数)
    zoj 3794 Greedy Driver
    zoj 3795 Grouping
    ASP.NET Core 简介
    ASP.NET Core 基础教程
    iOS ShareSDK Scheme
    微博授权失败 redirect_uri_mismatch
    集成友盟分享SDK报错
    获取设备实际宽度
  • 原文地址:https://www.cnblogs.com/KimKyeYu/p/3132251.html
Copyright © 2020-2023  润新知