solution.cpp 375 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <iostream>
using namespace std;
int num[5][1010] = {0};
int dp(int k, int n)
{
	int res = 10000;
	if (n == 0)
		return 0;
	if (k == 1)
		return n;
	if (num[k][n])
		return num[k][n];
	for (int i = 1; i <= n; i++)
	{
		res = min(res, max(dp(k - 1, i - 1), dp(k, n - i)) + 1);
	}
	num[k][n] = res;
	return res;
}
int main()
{
	cout << dp(3, 1000) << endl;
	return 0;
}