reproduced in http://blog.csdn.net/c20190413/article/details/77396357###;
Packing problem Description a factory-made product shapes are cuboid, their height is H, long and wide are equal, a total of six models, their long width is 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are usually packaged with a 6*6*h cuboid package and mailed to the customer. Because the postage is very expensive, the factory should find ways to reduce the number of parcels per order delivery. They need to have a good program to help them solve the problem and save money. Now this program is designed by you. The input file includes several lines, each representing an order. One line in each order consists of six integers, separated by spaces in the middle, and the number of six products 1*1 to 6*6 respectively. The input file ends with a line consisting of 6 0. Output In addition to the last line of input 6 0, each row in the input file corresponds to the output file row, each row of an integer to represent the corresponding order of the minimum number of packages required. Sample Input
0 0 4 0 0 1 7 5 1 0 0-
0
Sample Output
2
SourceEurope 1996
Analysis of Ideas
Code Implementation [cpp] View plain copy #include <bits/stdc++.h> using namespace std; int p1,p2,p3,p4,p5,p6,sum; Main () { while ( scanf ("%d%d%d%d%d%d", &P1,&P2,&P3,&P4,&P5,&P6) &&p1+p2+p3+p4+p5+p6) { sum=0; sum=p6+p5+p4; p1-=min (p1,p5*11); if (p2<p4*5) p1-=min (P1, (P4*5-P2) *4); p2-=min (p2,p4*5); p5=p4=0; sum+=ceil (p3/4.0); &nBsp p3%=4; if (p3==1) { if (p2<5) p1-=min (P1, (5-P2) *4); p1-=min (p1,7); p2-=min (p2,5); } if (p3==2) { if (p2<3) p1-=min (P1, (3-P2) *4); p1-=min (p1,6); p2-=min (p2,3); } if (p3==3) { if (!P2) p1-= Min (p1,4); p1-=min (p1,5); p2-=min (p2,1); } Sum+=ceil (p2/9.0); p2%=9; if (p2) p1-=min (p1,4* (9-P2)); sum+=ceil (p1/36.0); printf ( "%d\n", sum);