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 ( 1w, 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,最经典的一种领域操作,在无数的场合中都有着广泛的应用,作为一个很基础的函数,其性能的好 ...
随机推荐
- Blocks(POJ 3734 矩阵快速幂)
Blocks Input The first line of the input contains an integer T(1≤T≤100), the number of test cases. E ...
- swift字典集合-备
Swift字典表示一种非常复杂的集合,允许按照某个键来访问元素.字典是由两部分集合构成的,一个是键(key)集合,一个是值(value)集合.键集合是不能有重复元素的,而值集合是可以重复的,键和值是成 ...
- 用linux mail命令发送邮件[Linux]
mail [-s 邮件标题] <<邮件地址1> [邮件地址2] [邮件地址3]> [ < 包含邮件内容的文件路径 ] <-- -f 发送邮件地址> [-F 显 ...
- Map的三种遍历
import java.util.*;/*** Map的三种遍历方式* @author Administrator**/public class m {public static void main( ...
- 从客户端(txtNewsContent="<hr />")中检测到有潜在危险的 Request.Form 值。怎么办呀?
<system.web><httpRuntime requestValidationMode="2.0" executionTimeout="3600& ...
- 64位调试器花费的时间比预期的要长(A 64-bit debugging operation is taking longer than expected)
在stackoverflow上找到解决方案的: http://stackoverflow.com/questions/21329899/vs2013-professional-local-64-bit ...
- 图论:2-SAT模板
#include<cstdio> #include<vector> #include<cstring> using namespace std; const int ...
- 修改xcode代码风格设置
1.找到文件:/Applications/Xcode.app/Contents/PlugIns/IDECodeSnippetLibrary.ideplugin/Contents/Resources/S ...
- <php>PDO用法一
<?php //造PDO对象 $pdo = new PDO("mysql:dbname=mydb;host=localhost","root"," ...
- WPF - Build Error总结
1. are you missing an assembly reference 给项目添加新控件的时候,经常发现这种错误 Error 21 The type or namespace name 'C ...