有8万元的投资可以投给3个项目,每个项目在不同投资数额下(以万元为单位)的利润如下表。
请安排投资计划,使总的利润最大。
写出你所设的状态变量、决策变量、状态转移方程与递推关系式,和手工求解的详细步骤及结果。
#include <stdio.h>
#include <stdlib.h>
struct best_choice {
int dp; // 赚的钱
int index_g; // 当前第k个项目投资额
int index_f; // 从k+1 ... n所有项目投资额
};
struct best_choice best_choice[3][9] = {0};
int project[3][9] = {
{0, 5, 15, 40, 80, 90, 95, 98, 100},
{0, 5, 15, 40, 60, 70, 73, 74, 75},
{0, 4, 26, 40, 45, 50, 51, 52, 53}};
void show_index(int i, int j) {
if (i == 2) {
printf("第%d个项目投资%d万元\n", i + 1, j);
return;
}
else {