Question: 311-packets
The number of boxes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6 is given. Now there are several boxes 6*6, ask the minimum number of boxes that can be used to pack a given box.
Solution: For 6*6 boxes, each of them consumes one box.
For 5*5 boxes, 11 more 1*1 boxes can be installed.
For 4*4 boxes, 5 2*2 boxes can be installed after this is installed, and then 2*2 boxes can be supplemented with 1*1.
3x3 boxes:
1 3*3 box, 5 2*2 boxes, 7 1*1;
Same appeal format: 2 3 6
3 1 5
If two is required, 1 is used.
Code:
# Include <stdio. h> const int n = 6; int Packets [N]; // fill in the Void need () {If (Packets [1] <0) of 2*2) {Packets [0] + = Packets [1] * 4; Packets [1] = 0 ;}// determine the special situation of 3*3 void judge (int, int B) {Packets [1]-= A; Packets [0]-= B; need ();} int solve () {int sum = Packets [5]; int temp; For (INT I = N-2; I> = 1; I --) {if (I = 4) {sum + = Packets [I]; packets [0]-= 11 * Packets [I];} else if (I = 3) {sum + = Packets [I]; Pack ETS [1]-= Packets [I] * 5; need ();} else if (I = 2) {sum + = Packets [I]/4; packets [I] % = 4; If (Packets [I] = 3) {sum ++; Judge (1, 5);} else if (Packets [I] = 2) {sum ++; Judge (3, 6);} else if (Packets [I] = 1) {sum ++; Judge (5, 7 );}} else {temp = Packets [1] * 4; If (Packets [0]> 0) temp + = Packets [0]; sum + = (temp + 35) /36 ;}} return sum;} int main () {int count; while (1) {COUNT = 0; For (INT I = 0; I <N; I ++) {Scanf ("% d", & Packets [I]); count + = Packets [I];} If (! Count) break; printf ("% d \ n", solve () ;}return 0 ;}