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,最经典的一种领域操作,在无数的场合中都有着广泛的应用,作为一个很基础的函数,其性能的好 ...
随机推荐
- 【object-c基础】Object-c基础之三:面对对象开发@interface,@implementation
1.@interface 在java等语言编程中,创建类都是用class,但在object-c中,用@interface. 例子: @interface circle :NSObject //定 ...
- HTTP服务负载均衡总结
从一开始就要思考扩展的架构,所谓可扩展性指的是通过扩展规模提高承载能力的本领,往往体现在增加物理服务器或者集群节点.负载均衡是常见的水平扩展的手段. 目标:(1)减少单点故障(2)提升整体吞吐量(3) ...
- STARTUP.A51详解
STARTUP.A51 这个文件有什么用,有必要添加到工程吗? 如果不添加"startup.a51"文件,编译器就会自动加入一段初始化内存以及堆栈等的代码,这时的内存初始化部分你就 ...
- Cmake,链接一个外部(也可能是第三方,也可能是自己编译的)库
相当于设置VS工程里面的: 然后,为了链接成可执行文件,链接器就会到指定的目录寻找相应的库了. 以下时Demo: cmake_minimum_required(VERSION 2.8) #set(CM ...
- 在Fragment中实现百度地图,定位到当前位置(基于SDKv2.1.0)
使用最新版本的百度地图需要注意的几个地方: 1.libs文件夹下要有android-support-v4.jar.baidumapapi_v2_1_0.jar.locSDK_3.1.jar三个jar包 ...
- quote, quasiquote, unquote和unquote-splicing
关于符号类型 符号类型又称引用类型,在概要一文中本人介绍得非常的模糊,使很多初学者不理解.符号类型在Scheme语言中是最基础也是最重要的一种类型,这是因为Scheme语言的祖先Lisp语言的最初目的 ...
- 如何使用git创建项目,创建分支
git config -global user.name "Your name" git config -global user.email "you@example.c ...
- cf492A Vanya and Cubes
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- java实现矩阵连乘的动态规划
package com.cjs.algorithm; public class DynamicPlan { /** * 此方法用来求解矩阵连乘的最小数乘次数 * * @param p * 传入的要连乘 ...
- "V租房"搭建微信租房平台,让租房人发起求租需求并接收合适房源回复,提高租房效率 | 36氪
"V租房"搭建微信租房平台,让租房人发起求租需求并接收合适房源回复,提高租房效率 | 36氪 "V租房"搭建微信租房平台,让租房人发起求租需求并接收合适房源回复 ...