poj 2160 Box 模拟
来源:互联网 发布:淘宝教育怎么入驻 编辑:程序博客网 时间:2024/06/08 14:19
题意:
给6块木板的长度,判断它们是否可以组成一个长方体。
分析:
模拟,首先判断6块木板是否可以分为3组完全相等的木板,再判断这3组木板是否能组成长方体。
代码:
//poj 2160//sep9#include <iostream>#include <algorithm>using namespace std;int vis[8];int x[8],y[8];int a[8];int main(){int i,j;for(i=0;i<6;++i){scanf("%d%d",&x[i],&y[i]);if(x[i]>y[i])swap(x[i],y[i]);}int cnt=0,t=0;memset(vis,0,sizeof(vis));for(i=0;i<6;++i){if(vis[i]==0){vis[i]=1;for(j=0;j<6;++j)if(vis[j]==0&&x[j]==x[i]&&y[j]==y[i]){vis[j]=1;a[t++]=x[i];a[t++]=y[i];++cnt;break;}}}if(cnt==3){sort(a,a+6);if(a[0]==a[1]&&a[2]==a[3]&&a[4]==a[5])printf("POSSIBLE");elseprintf("IMPOSSIBLE");}elseprintf("IMPOSSIBLE");}
0 0
- poj 2160 Box 模拟
- poj-2160 BOX
- POJ 2160 Box G++
- POJ 2160 BOX
- 优先队列模拟最大堆和最小堆,poj 1442 Black Box
- poj 2504 Bounding box
- poj 1442 Black Box
- poj 2977 Box walking
- POJ 1442 Black Box
- poj--1442--black box
- POJ 1442 Black Box
- POJ 1442 Black Box
- POJ 1442 Black Box
- POJ 1442 Black Box
- poj 1442 Black Box
- POJ 1442 Black Box
- POJ 1442 Black Box
- POJ 1442 Black Box
- DRIVER_INFO_6 structure
- poj 1208 The Blocks Problem 模拟+vector的使用
- Android多线程断点下载文件
- Longest Substring Without Repeating Characters
- Leetcode - Add Binary -Jan 30, 2015
- poj 2160 Box 模拟
- DevCon 命令行实用工具可替代设备管理器
- HTML5 声明兼容IE的写法
- 养成定时更新内容的好习惯,提高搜索引擎时效性收录
- lv官方網 wqdx axsr jguq
- 最大子列和问题
- Two Sum Closest to K
- django提交表单提示"You called this URL via POST, but the URL doesn't end in a slash and you have APPEND_SL
- 403-In general, this can occur when there is a genuine Cross Site Request Forgery, or whe