1.链接地址:

http://poj.org/problem?id=1017

http://bailian.openjudge.cn/practice/1017

2.题目:

总时间限制:
1000ms
内存限制:
65536kB
描述
一个工厂制造的产品形状都是长方体,它们的高度都是h,长和宽都相等,一共有六个型号,他们的长宽分别为1*1, 2*2, 3*3, 4*4, 5*5, 6*6。这些产品通常使用一个 6*6*h 的长方体包裹包装然后邮寄给客户。因为邮费很贵,所以工厂要想方设法的减小每个订单运送时的包裹数量。他们很需要有一个好的程序帮他们解决这个问题从而节 省费用。现在这个程序由你来设计。
输入
输入文件包括几行,每一行代表一个订单。每个订单里的一行包括六个整数,中间用空格隔开,分别为1*1至6*6这六种产品的数量。输入文件将以6个0组成的一行结尾。
输出
除了输入的最后一行6个0以外,输入文件里每一行对应着输出文件的一行,每一行输出一个整数代表对应的订单所需的最小包裹数。
样例输入
0 0 4 0 0 1
7 5 1 0 0 0
0 0 0 0 0 0
样例输出
2
1
来源
Central Europe 1996

3.思路:

数学题,分为多种情况

4.代码:

 #include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
const int NUM = ;
int res[NUM];
int main()
{
int x6,x5,x4,x3,x2,x1;
cin>>x1>>x2>>x3>>x4>>x5>>x6;
while(x1 + x2 + x3 + x4 + x5 + x6 > )
{
for(int i = ; i < NUM; i++) res[i] = ;
int sum = ; sum += x6; sum += x5;
res[] -= *x5; sum += x4;
res[] -= *x4; sum += x3/;
int tmp = x3 % ;
if(tmp == )
{
sum += ;
res[] -= ;
res[] -= ;
}
else if(tmp == )
{
sum += ;
res[] -= ;
res[] -= ;
}
else if(tmp == )
{
sum += ;
res[] -= ;
res[] -= ;
} if(x2 + res[] <= ) res[] += * (res[] + x2);
else
{
sum += (x2 + res[] + ) / ;
res[] -= ( - (x2 + res[]) % ) * ;
} if(x1 + res[] > ) sum += (x1 + res[] + ) / ; cout<<sum<<endl; cin>>x1>>x2>>x3>>x4>>x5>>x6;
}
return ;
}

Poj 1017 / OpenJudge 1017 Packets/装箱问题的更多相关文章

  1. Poj 2109 / OpenJudge 2109 Power of Cryptography

    1.Link: http://poj.org/problem?id=2109 http://bailian.openjudge.cn/practice/2109/ 2.Content: Power o ...

  2. Poj 1328 / OpenJudge 1328 Radar Installation

    1.Link: http://poj.org/problem?id=1328 http://bailian.openjudge.cn/practice/1328/ 2.Content: Radar I ...

  3. Poj 2503 / OpenJudge 2503 Babelfish

    1.Link: http://poj.org/problem?id=2503 http://bailian.openjudge.cn/practice/2503/ 2.Content: Babelfi ...

  4. Poj 2262 / OpenJudge 2262 Goldbach's Conjecture

    1.Link: http://poj.org/problem?id=2262 http://bailian.openjudge.cn/practice/2262 2.Content: Goldbach ...

  5. Poj 2159 / OpenJudge 2159 Ancient Cipher

    1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...

  6. Poj 1001 / OpenJudge 2951 Exponentiation

    1.链接地址: http://poj.org/problem?id=1001 http://bailian.openjudge.cn/practice/2951 2.题目: Exponentiatio ...

  7. Poj 1006 / OpenJudge 2977 1006 Biorhythms/生理周期

    1.链接地址: http://poj.org/problem?id=1006 http://bailian.openjudge.cn/practice/2977 2.题目: Biorhythms Ti ...

  8. Poj 2586 / OpenJudge 2586 Y2K Accounting Bug

    1.Link: http://poj.org/problem?id=2586 2.Content: Y2K Accounting Bug Time Limit: 1000MS   Memory Lim ...

  9. 毫秒级检测!你见过带GPU的树莓派吗?

    树莓派3B+英特尔神经计算棒进行高速目标检测 转载请注明作者梦里茶 代码: 训练数据预处理: https://gist.github.com/ahangchen/ae1b7562c1f93fdad1d ...

随机推荐

  1. Languages

    Languages A language class exists inside the system/Core folder, this class have 2 methods: load - L ...

  2. IIS 之 查看并发连接数

    如果要查看IIS连接数,最简单方便的方法是通过“网站统计”来查看,“网站统计”的当前在线人数可以认为是当前IIS连接数.然而,“网站统计”的当前在线人数统计时间较长,一般为10分钟或15分钟,再加上统 ...

  3. felx第二天 ActionScript 基本语法和关键字

    flex中使用的注解有两种分别是:// 和/**/ flex使用的关键字如图

  4. 对JavaScript对象数组按指定属性和排序方向进行排序

    引子 在以数据为中心的信息系统中,以表格形式展示数据是在常见不过的方式了.对数据进行排序是必不可少的功能.排序可以分为按单个字段排序和按多个字段不同排序方向排序.单字段排序局限性较大,不能满足用户对数 ...

  5. 一款仿36氪iOS版APP源码

    Features 离线缓存 解决视频播放器的网速慢卡顿 视频播放器调用简单 cell自适应高度 cell中嵌套webView cell中嵌套webView 条件实时搜索 Known problems ...

  6. C语言创建并使用lib

    本文试图以比较简洁的方式创建lib: 只求能够把lib用起来,并不会加上[很多但必须的东西,比如我们之前说过的#ifndef #define 和#endif] 打开vs 创建一个新的项目: 点击确定 ...

  7. VSPackge插件系列:常用IDE功能的封装

    继上一篇VSPackge插件系列简单介绍如何正确的获取DTE之后,就一直没发VSPackge插件系列的文章了,最近同事也想了解如何在代码中与VS交互,特发一篇文章示例一些简单功能是如何调用,也以备以后 ...

  8. Centos 6.5 安装 chrome , mplayer , alarm , clock

    http://my.oschina.net/jianweizhang/blog/306946 Chrome wget http://chrome.richardlloyd.org.uk/install ...

  9. PHP自动化测试

    参考网址: 1. 基于Jenkins 实现php项目的自动化测试.自动打包和自动部署 2.  PHP Jenkins,参考:http://jenkins-php.org/ 3.安装PHP_CodeSn ...

  10. 301页面转向 php

    新建301.php页面,在程序入口文件index.php引用301.php页面 301.php内容如下,仅用于参考: <?php$the_host = $_SERVER['HTTP_HOST'] ...