#include <bits/stdc++.h>
using namespace std;
const int N = 20 + 1, INF = 0x3f3f3f3f;
int f[N][N][N], w, h, m;
void solve();
int main()
{
while(scanf("%d%d%d", &w, &h, &m) != EOF){
if(w == 0 && h == 0 && m == 0) break;
solve();
printf("%d\n", f[w][h][m]);
}
return 0;
}
void solve()
{
memset(f, 0, sizeof(f));
int i, j, k;
int t, p;
for(i = 1; i <= w; i++){
for(j = 1; j <= h; j++){
f[i][j][1] = i*j;
}
}
for(i = 1; i <= w; i++){
for(j = 1; j <= h; j++){
for(k = 2; k <= min(i*j, m); k++){
f[i][j][k] = INF;
//横着切
for(t = 1; t < i; t++){
for(p = 1; p < k; p++){
f[i][j][k] = min(f[i][j][k], max(f[t][j][p], f[i - t][j][k - p]));
}
}
//竖着切
for(t = 1; t < j; t++){
for(p = 1; p < k; p++){
f[i][j][k] = min(f[i][j][k], max(f[i][t][p], f[i][j - t][k - p]));
}
}
}
}
}
}
程序设计实习MOOC / 程序设计与算法(二)测验汇总(2019春季) 017
最新推荐文章于 2022-12-28 15:10:47 发布