#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main(){ int a,b,c,d,e,f;//六类货品 int box;//箱子数字 int three[4]{0,5,3,1};//3*3箱子%4==0 1 2 3 可以放几个2*2?? cin>>a>>b>>c>>d>>e>>f; box=d+e+f+(int)ceil(c*1.0/4);//6*6 5*5 4*4 以及3*3必须要新箱子, 5个3*3需要 ceil(5/4)=2 ceil向上取整 int spacetwo= d*5+three[c%4]; if(b>spacetwo){//2*2的数量比空着的2*2多,又要开箱子 box+=(int)ceil((b-spacetwo)*1.0/9);//把剩余的 2*2 安置好需要几个新箱子? } int spaceone=box*36-f*36-e*25-d*16-c*9-b*4;//1*1的位置 用箱子总面积减去各个种类的面积剩下的都可以放1*1 if(a>spaceone){//1*1填补空余之后还有多的 ,再开箱子 box+=(int)ceil((a-spaceone)*1.0/36);//把剩余的1*1安置好需要几个箱子? } cout<<box<<endl; } |
Double click to view unformatted code.