高雄市98資訊學科能力競賽 第三題:產品包裝
作法 : ?
首先知道邊長4的個數 N 必定需要 N個4*4*4包
再來是邊長3的個數 N 也必定需要 N個 4*4*4包
再來是邊長2的個數 N 卻只需要(int)N/8+(N%8!=0) 個 4*4*4包
剩下的邊長1的個數 N 就得看看 邊長3所用的包 跟 邊長2所用的包
有沒有足夠剩餘的個數了
/****************************************************************/
#include<stdlib.h>
#include<stdio.h>
main()
{
int t1,t2,t3,t4;
while(scanf("%d %d %d %d",&t1,&t2,&t3,&t4)==4)
{
int sum=t4+t3;
int s1=t3*64-t3*27;
if(s1>=t1) t1=0;
else t1-=s1;
sum=sum+t2/8;
if(t2%8!=0)
{
int s2=64-(t2%8)*8;
if(s2>=t1) t1=0;
else t1-=s2;
sum++;
}
printf("%d\n",sum+t1/64+t1%64);
}
return 0;
}