UVA 1587
来源:互联网 发布:知乎的目的 编辑:程序博客网 时间:2024/06/01 09:59
题目大意:给6个面,每个面有长宽,问能否组成一个长方体。
解题思路:按长>宽的优先级排序,结果要求第一个与第二个,第三个与第四个,第五个与第六个面完全相同。且第一个面的长与第三个面的长相同,第一个面的宽与第五个面的长相同,第二个面的宽与第五个面的宽相同。
ac代码:
#include <iostream>#include <algorithm>using namespace std;struct node{int length;int weight;}no[6];int n, m, jud;bool compare(node a, node b){if (a.length != b.length)return a.length > b.length;return a.weight > b.weight;}void convet(int i){if (n > m)no[i].length = n, no[i].weight = m;elseno[i].length = m, no[i].weight = n;}int main(){while (scanf("%d%d", &n, &m)!=EOF){jud = 1;convet(0);for (int i=1; i<6; i++){scanf("%d%d", &n, &m);convet(i);}sort(no, no+6, compare);for (int i=0; i<6; i+=2)if (no[i].length != no[i+1].length || no[i].weight != no[i+1].weight)jud = 0;if (no[0].length != no[2].length || no[0].weight != no[4].length|| no[2].weight != no[4].weight)jud = 0;if (jud)printf("POSSIBLE\n");elseprintf("IMPOSSIBLE\n");}return 0;}
0 0
- UVa.1587
- UVA-1587
- UVA 1587
- UVa 1587
- UVa 1587
- uva 1587 - Box
- uva 1587 - Box
- UVa 1587 - Box
- UVa 1587 - Box
- UVa 1587 Box
- Uva-1587-Box-AC
- UVA - 1587 Box
- UVa 1587 Box
- Box UVa 1587
- UVA - 1587 Box 麻烦
- UVa 1587 - Box
- UVa 1587 - Box
- UVa-1587 - Box
- 商城 商品模块 数据库 表设计
- HDU1370 Biorhythms【中国剩余定理】
- Altium Designer 09简易教程(一)
- 这点必须服刘强东!地震时库管有无上权力
- 转载:Reactor模式详解
- UVA 1587
- 算法导论基本数据结构
- Java异常处理机制以及try-catch-finally-return执行顺序
- 分页1-5之间跳转代码
- 我用Xamarin开发android应用,应用在真机上一打开就退出了
- servlet介绍
- JavaScript学习-DOM2和DOM3的变化
- 数据库系统概论学习攻略(第四期)
- bootstrapTable mergeCells