习题 3-10 盒子(Box, ACM/ICPC NEERC 2004, UVa1587)
题目描述:给定6个矩形的长和宽wi和hi (1<=wi,hi<=10000),判断它们能否构成长方体的6个面。
难就难在明白构成长方体的充要条件,想明白这个,此题就解决了。
我的思路是6个矩形两两相等(前后、上下、左右),然后去掉重复的矩形,剩下的正好可以拼合
代码如下:
#include<stdio.h>
#include<algorithm>
using namespace std;
int w[6], h[6];
int num[6];
int main(){
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
while(scanf("%d%d%d%d%d%d%d%d%d%d%d%d", &w[0], &h[0], &w[1], &h[1], &w[2]