poj 1017 装箱子问题

#include
int main(void)
{
           int x1,x2,x3,x4,x5,x6,amount,x,y=0;        //x1,x2,x3,.....代表1x1 ,2x2.....的箱子
           while(~scanf("%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6))
           {
                       amount=0;y=0;
                       if(x1+x2+x3+x4+x5+x6==0)
                                    break;
                      amount=x6+x5+x4+(x3+3)/4;      //大小是6,5,4,的小箱子一个大箱子只能放一个,而3的小箱子,

                                                                   //一个大箱子放4个,但是有5个的时候,必须有2个大箱子,所以是(x3+3)/4
                      y=x4*5;   //已经确定了6,5,4,3小箱子的放置位置,现在看看2的箱子插到装有3或4小箱子的大箱子

                                                                  //的最大数目y
                      if(x3%4==3)
                              y+=1;
                      else
                          if(x3%4==2)
                                   y+=3;
                          else
                               if(x3%4==1)
                                     y+=5;
                     if(y                      {
                                 amount+=(x2-y+8)/9;
                     }

                      x=36*amount-36*x6-25*x5-16*x4-9*x3-4*x2;//6,5,4,3,2箱子已经确定好了,看看1小箱子可以插入

                                                                                                       //到他们的间隙中的最大数目x。
                     if(x                      {
                           amount+=(x1-x+35)/36;
                     }
                     printf("%d\n",amount);


            }
}

你可能感兴趣的:(ACM,poj)