递归与分治经典例题 要点在于对3*3箱子的讨论
#include <iostream> #include <cstdio> using namespace std; int main() { // freopen("in.txt","r",stdin); int s1[]={0,7,6,5}; int s2[]={0,5,3,1}; int n1,n2,n3,n4,n5,n6,t1,t2,sum; while(cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6,!(n1==0&&n2==0&&n3==0&&n4==0&&n5==0&&n6==0)) { sum=n6+n5+n4+n3/4; if(n3%4) { sum++; } t1=n5*11+s1[n3%4]; t2=n4*5+s2[n3%4]; n2=n2-t2; if(n2>0) { sum=sum+n2/9; if(n2%9) { sum++; } t1=t1+36-(n2%9)*4; } else { t1=t1-4*n2; } n1=n1-t1; if(n1>0) { sum=sum+n1/36; if(n16>0) sum++; } cout << sum << endl; } return 0; }