题目大概:

每个箱子能放6*6的大小的东西,分别有六种大小的物品,1*1..2*2..3*3...4*4。5*5  .6*6,问最少许雅io多少箱子。

思路:

高度不考虑了,只算大小。

1。。。6*6  一个占一个箱子。

2。。。5*5,占一个箱子在用1*1的补上空位。

3。。。4*4,占一个箱子,用2*2  1*1补位。

4。。。3*3,四个刚好一个箱子,当少于四个时,用2*2  1*1补位。

5。。。最后2*2  和1*1  直接计算有多少个箱子。

代码:


#include<iostream>
#include<cstdio>
using namespace std;
int b[7], cot;int main()
{

while(1){
for(int i=0;i<6;i++){
scanf("%d",&b[i]);
}
int flag=0;
for(int i=0;i<6;i++){
if(b[i]==0) flag ++;
}
if(flag == 6) break;


cot = 0;
if(b[5] != 0){
cot+=b[5];
}

if(b[4] != 0){
cot+=b[4];
int x = b[4]*11;
b[0] = b[0]-x>=0?b[0]-x:0;
}

if(b[3] != 0){
int res = 0;
cot+=b[3];
res = 20*b[3];
if(b[1] != 0) {
int x = b[1] / 5;
if( x >= b[3]) { b[1] = b[1] - b[3]*5; res = 0; }
else { res -= b[1]*4; b[1] = 0; }
}
if(b[0] != 0&& res != 0) {
b[0] = b[0]>res?b[0]-res:0;
}
}

if(b[2] != 0) {
int x = b[2] / 4, y = b[2] % 4;
int res = 0;
cot += x;
if(y != 0) cot++;
if(y == 1){
res = b[1] > 5?7:27-b[1]*4;
b[1] = b[1] > 5? b[1]-5:0;
}
if(y == 2){
res = b[1]>3? 6:18-b[1]*4;
b[1] = b[1] > 3? b[1]-3:0;
}
if(y == 3){
if(b[1] != 0) { res = 5; b[1] --; }
else res = 9;
}

if(res != 0&&b[0] != 0) b[0] = b[0]>res?b[0]-res:0;
}

if(b[1] != 0){
int y = b[1] % 9;
cot += b[1]/9;
if(y != 0) {
cot++;
y = 36 - y*4;
b[0] = b[0]>y?b[0]-y:0;
}
}

if(b[0] != 0) {
cot += (b[0] / 36);
b[0] %= 36;
if(b[0] != 0) cot++;
}

printf("%d\n", cot);
}
return 0;
}