pku 1017 Packets

来源:互联网 发布:mysql 查看表锁定状态 编辑:程序博客网 时间:2024/05/31 19:29

http://acm.pku.edu.cn/JudgeOnline/problem?id=1017
题意是给你面积大小为1*1,2*2,3*3,4*4,5*5,6*6的物品个数,问最少需要几个6*6的包包来装。
#include <stdio.h>

int res[4] = {0,5,3,1};

int main()
{
 int a,b,c,d,e,f,x,y,total,sum;
 while(1)
 {
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
  sum = a + b + c + d + e + f;
  if(sum == 0)
   break;
  total = f + e + d + (c+3)/4;
  x = 5*d + res[c%4];//面积为三的物品的数量
  if(b > x)
   total = total + (b-x+8)/9;
  y = 36*total - 36*f - 25*e - 16*d - 9*c - 4*b;//面积为一的物品的数量
  if(a > y)
   total = total + (a-y+35)/36;
  printf("%d/n",total);
 }

 return 0 ;
}


/*
0 0 4 0 0 1
7 5 1 0 0 0
0 0 0 0 0 0

 

2
1
*/

原创粉丝点击