#include using namespace std; int best[21][21][21]; int getBest(int w, int h, int m) { if (best[w][h][m] > 0) return best[w][h][m]; if (m == 1) return w*h; int x = 20*20; for (int t = 0; t < 2; t++) { for (int i = 1; i <= w-1; i++) for (int j = 1; j <= m-1; j++) { int y1 = getBest(i, h, j); int y2 = getBest(w-i, h, m-j); y1 >?= y2; x > w >> h >> m; if (w*h*m == 0) return 0; cout << getBest(w,h,m) << endl; } }