题目大意,给你n种模型1*1,2*2,3*3,4*4,5*5,6*6,一个箱子最多可以容纳6*6,问多少箱子可以装满这些模型;
解题思路:
纯模拟,我也压根不擅长也模拟;
有一个坑:如果3*3模型%9后若为0 则不能进行2*2和1*1的填充操作,
2*2的也是如此。我忽视了这一点。
AC代码:
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <fstream>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <iostream>
#include <algorithm>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
#define maxn 1010
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ms(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<(n);i++)
#define repf(i,a,b) for(int i=(a);i<=(b);i++)
#define pii pair<int,int>
//#define mp make_pair
#define FI first
#define SE second
#define IT iterator
#define PB push_back
#define Times 10
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int ,int > P;
const double eps = 1e-10;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const ll INF = (ll)1e18+300;
const int maxd = 50500 + 10;
int a[16];
int ini[5] = {0,5,3,1};
int main() {
while(1) {
int flag = 0;
for (int i = 1; i <= 6;i++) {
cin >> a[i];
if(a[i] != 0) {
flag = 1;
}
}
if(!flag) {
break;
}
int ans = a[6];
int res = 36;
ans += a[5];
a[1] = max(0, a[1] - 11 * a[5]);
ans += a[4];
res = 36 * a[4];
res -= 4 * 4 * a[4];
res -= min(a[2] * 4, 5 * a[4] * 4);
a[2] = max(0, a[2] - 5 * a[4]);
a[1] = max(0, a[1] - res);
ans += a[3] / 4;
a[3] = a[3] % 4;
if(a[3]) {
ans ++;
res = 36 - a[3] * 9;
res -= min(a[2] * 4, ini[a[3]] * 4);
a[2] = max(0, a[2] - ini[a[3]]);
a[1] = max(0, a[1] - res);
}
ans += a[2]/9;
a[2] = a[2] % 9;if(a[2]) {ans ++;
res = 36 - a[2] * 4;
a[1] = max(0, a[1] - res);}
ans += a[1]/36;
a[1] = a[1] % 36;
if(a[1]) {
ans ++;
}
cout << ans << endl;
}
}