uva1587 Box
Ivan works at a factory that produces heavy machinery. He has a simple job -- he knocks up wooden boxes of different sizes to pack machinery for delivery to the customers. Each box is a rectangular parallelepiped. Ivan uses six rectangular wooden pallets to make a box. Each pallet is used for one side of the box.

Joe delivers pallets for Ivan. Joe is not very smart and often makes mistakes -- he brings Ivan pallets that do not fit together to make a box. But Joe does not trust Ivan. It always takes a lot of time to explain Joe that he has made a mistake. Fortunately, Joe adores everything related to computers and sincerely believes that computers never make mistakes. Ivan has decided to use this for his own advantage. Ivan asks you to write a program that given sizes of six rectangular pallets tells whether it is possible to make a box out of them.
Input
Input file contains several test cases. Each of them consists of six lines. Each line describes one pallet and contains two integer numbersw and h ( 1
w, h
10 000) -- width and height of the pallet in millimeters respectively.
Output
For each test case, print one output line. Write a single word ` POSSIBLE' to the output file if it is possible to make a box using six given pallets for its sides. Write a single word ` IMPOSSIBLE' if it is not possible to do so.
Sample Input
1345 2584
2584 683
2584 1345
683 1345
683 1345
2584 683
1234 4567
1234 4567
4567 4321
4322 4567
4321 1234
4321 1234
Sample Output
POSSIBLE
IMPOSSIBLE 希望每次代码都有进步。
AC代码:
#include<iostream> using namespace std; struct Box
{
int a,b;
} box[]; void Swap(int *,int *);
void Sort();
int Judge(); int main()
{
while(cin >> box[].a >> box[].b)
{
if(box[].a<box[].b)
Swap(&box[].a,&box[].b);
for(int i=; i<; i++)
{
cin >> box[i].a >> box[i].b;
if(box[i].a<box[i].b)
Swap(&box[i].a,&box[i].b);
}
Sort();
if(Judge())
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
}
return ;
}
void Swap(int *p,int *q)
{
int r;
r=*p;
*p=*q;
*q=r;
} void Sort()
{
struct Box c;
for(int i=; i<; i++)
for(int j=; j<-i; j++)
{
if(box[j].a<box[j+].a)
{
c=box[j];
box[j]=box[j+];
box[j+]=c;
}
}
for(int i=; i<; i++)
for(int j=; j<-i; j++)
{
if(box[j].b<box[j+].b&&box[j].a==box[j+].a)
{
c=box[j];
box[j]=box[j+];
box[j+]=c;
}
}
} int Judge()
{
if(box[].a==box[].a&&box[].a==box[].a&&box[].a==box[].a)
if(box[].b==box[].b&&box[].b==box[].a&&box[].a==box[].a)
if(box[].b==box[].b&&box[].b==box[].b&&box[].b==box[].b)
return ;
return ;
}
uva1587 Box的更多相关文章
- [刷题]算法竞赛入门经典 3-10/UVa1587 3-11/UVa1588
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 题目:算法竞赛入门经典 3-10/UVa1587:Box 代码: //UVa1587 - Box #include&l ...
- BOX (UVA-1587) 比较代码书写上的差距
对比一下代码的书写差距: 我的代码: #include<iostream> using namespace std; ]; ]; ]; //访问标记 bool judge(int i, i ...
- Virtual Box配置CentOS7网络(图文教程)
之前很多次安装CentOS7虚拟机,每次配置网络在网上找教程,今天总结一下,全图文配置,方便以后查看. Virtual Box可选的网络接入方式包括: NAT 网络地址转换模式(NAT,Network ...
- Linux监控工具介绍系列——OSWatcher Black Box
OSWatcher Balck Box简介 OSWatcher Black Box (oswbb)是Oracle开发.提供的一个小巧,但是实用.强大的系统工具,它可以用来抓取操作系统的性能指标,用 ...
- 使用packer制作vagrant centos box
使用packer制作vagrant box:centos 制作vagrant box,网上有教程,可以自己step by step的操作.不过直接使用虚拟在VirtualBox中制作vagrant b ...
- 快速打造跨平台开发环境 vagrant + virtualbox + box
工欲善其事必先利其器,开发环境 和 开发工具 就是 我们开发人员的剑,所以我们需要一个快并且好用的剑 刚开始做开发的时候的都是把开发环境 配置在 自己的电脑上,随着后面我们接触的东西越来越多,慢慢的电 ...
- CSS3伸缩盒Flexible Box
这是一种全新的布局,在移动端非常实用,IE对此布局的相关的兼容不是很好,Firefox.Chrome.Safrai等需要加浏览器前缀. 先说说这种布局的特点: 1)移动端由于屏幕宽度都不一样,在布局的 ...
- CSS3与页面布局学习总结(二)——Box Model、边距折叠、内联与块标签、CSSReset
一.盒子模型(Box Model) 盒子模型也有人称为框模型,HTML中的多数元素都会在浏览器中生成一个矩形的区域,每个区域包含四个组成部分,从外向内依次是:外边距(Margin).边框(Border ...
- 解析opencv中Box Filter的实现并提出进一步加速的方案(源码共享)。
说明:本文所有算法的涉及到的优化均指在PC上进行的,对于其他构架是否合适未知,请自行试验. Box Filter,最经典的一种领域操作,在无数的场合中都有着广泛的应用,作为一个很基础的函数,其性能的好 ...
随机推荐
- 使用redis缓存加索引处理数据库百万级并发
使用redis缓存加索引处理数据库百万级并发 前言:事先说明:在实际应用中这种做法设计需要各位读者自己设计,本文只提供一种思想.准备工作:安装后本地数redis服务器,使用mysql数据库,事先插入1 ...
- 蚁群算法matlab实现
大家好,我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang 以下用matlab实现蚁群算法: %蚂蚁算法test %用产生的一个圆上的十个点来检验蚂蚁 ...
- DOM commend
var comment = document.createComment("commend content"); var elem = document.getElementByI ...
- LeetCode_Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...
- 如何解决Bluetooth系统设计的棘手问题
我们若想设计一套完善的蓝牙 (Bluetooth) 系统,就必须充分掌握其中的技术知识,例如协议堆栈.射频设计及系统集成等方面的专门知识.LMX9820 芯片的面世令蓝牙系统的设计工作变得更为容易.以 ...
- WPF:如何实现单实例的应用程序(Single Instance)
原文:WPF:如何实现单实例的应用程序(Single Instance) 好吧,这是我将WPF与Windows Forms进行比较的系列文章的第四篇,讨论一下如何实现单实例(single instan ...
- Cmake编译成静态库
To build OpenCV as static library you need to set BUILD_SHARED_LIBS flag to false/off: cmake -DBUILD ...
- Cmake find_package()相关
也就是find_package可以帮助直接找到库的头文件和库文件(.lib,dll .etc) References: http://blog.csdn.net/dbzhang800/article/ ...
- android 之 百度地图
简介 百度地图Android定位SDK为基于移动客户端开发LBS应用提供基础定位能力. 功能介绍 功能介绍: 地图展示:包括2D图.卫星图.3D图地图展示. 地图操作:提供控制平移.缩放.底图旋转.变 ...
- cf493A Vasya and Football
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...