1017 Packing Problem

Subject description:

Describes a plant for manufacturing a product shape is rectangular, the height thereof is H, the length and width are equal, a total of six models, and their length and width were 1 1 *, 2 * 2, 3 *, 4 * 4, 5 5 *, 6 * 6. These products typically use a 6 * 6 * h rectangular package wrapped and mailed to the customer. Because Free expensive, so the number of parcels at each factory orders shipped to find ways to decrease. They need to have a very good program to help them solve this problem in order to save costs. Now this program be designed by you. Input file contains several lines, each line represents an order. Each order consists of six integers in a row, in the middle separated by a space, the number of these six products 1 * 1-6 * 6, respectively. Enter the file will be six zeros end of a line. Except for the last line of input output 6 0, the input file corresponding to each row line of the output file, each line of output integer representing a minimum number of required package corresponding line. Sample input

0 0 4 0 0 1 
7 5 1 0 0 0 
0 0 0 0 0 0 

Sample Output

2 
1 
#include<iostream>
using namespace std;
int main(){
    int N,a,b,c,d,e,f,y,x;
    int u[4]={0,5,3,1};
    while (1){
        cin>>a>>b>>c>>d>>e>>f;
        if (a==0 && b==0 && c==0 && d==0 && e==0 && f==0  ) break;
        N=f+e+d+(c+3)/4; 
        y=5*d+u[c%4];
        if (b>y)    N+=(b-y+8)/9;
        x=36*N-36*f-25*e-16*d-9*c-4*b;
        if (a>x) N+=(a-x+35)/36;    
        cout<<N<<endl;
    }
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/sweet-ginger-candy/p/11518184.html