博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Packets
阅读量:6230 次
发布时间:2019-06-21

本文共 2338 字,大约阅读时间需要 7 分钟。

Packets

Description

A factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parcels of the same height h as the products have and of the size 6*6. Because of the expenses it is the interest of the factory as well as of the customer to minimize the number of parcels necessary to deliver the ordered products from the factory to the customer. A good program solving the problem of finding the minimal number of parcels necessary to deliver the given products according to an order would save a lot of money. You are asked to make such a program.

Input

The input file consists of several lines specifying orders. Each line specifies one order. Orders are described by six integers separated by one space representing successively the number of packets of individual size from the smallest size 1*1 to the biggest size 6*6. The end of the input file is indicated by the line containing six zeros.

Output

The output file contains one line for each line in the input file. This line contains the minimal number of parcels into which the order from the corresponding line of the input file can be packed. There is no line in the output file corresponding to the last ``null'' line of the input file.

Sample Input

0 0 4 0 0 1

7 5 1 0 0 0

0 0 0 0 0 0

Sample Output

2

1

 

 

//告诉你1*1,2*2,3*3......6*6 方块的数量,问最少需要多少个容量为6*6的容器才能装下

 

//显然贪心可做,但是这题数据还是不弱的,wa了好几发。。要细心

1 #include 
2 using namespace std; 3 4 int box[7]; 5 int main() 6 { 7 while (1) 8 { 9 int all=0;10 for (int i=1;i<=6;i++)11 {12 scanf("%d",&box[i]);13 all+=box[i];14 }15 if (all==0) break;16 17 int ans = box[4]+box[5]+box[6];18 int x2 = 5*box[4];19 int x1 = 11*box[5];20 if (x2>box[2])21 {22 x1+=(x2-box[2])*4;23 x2=box[2];24 }25 26 int t=box[3]%4;27 if (t) ans++;28 ans += box[3]/4;29 if (t==1) x2+=5,x1+=7;30 if (t==2) x2+=3,x1+=6;31 if (t==3) x2+=1,x1+=5;32 if (x2>box[2])33 {34 x1+=(x2-box[2])*4;35 x2=box[2];36 }37 38 if (x2
View Code

 

转载于:https://www.cnblogs.com/haoabcd2010/p/6950631.html

你可能感兴趣的文章
聊聊单元測试(一)——EasyMock
查看>>
使用 Chrome 来调试你的 Android App
查看>>
ObjectOutputStream和ObjectInputStream
查看>>
微服务架构的设计模式
查看>>
【C++】继承时构造函数和析构函数
查看>>
android 点击屏幕关闭 软键盘
查看>>
开发中三个经典的原则
查看>>
nodejs基础 -- NPM 使用介绍
查看>>
指针之——一级二级多级指针
查看>>
Curl命令
查看>>
汽车常识全面介绍 - 引擎详论
查看>>
如何获取和发送Http请求和相应
查看>>
电子商务网站数据分析常用指标(转)
查看>>
HashSet中实现不插入重复的元素
查看>>
操作系统学习基本概念汇总
查看>>
用户IP地址的三个属性的区别(HTTP_X_FORWARDED_FOR,HTTP_VIA,REM_addr
查看>>
漫画:鉴权与安全访问控制的技术血脉
查看>>
179. Largest Number
查看>>
Git命令行大全
查看>>
JSt中对象的prototype属性
查看>>