采药,程序有问题,出错的数据附上,在注释中
#include
#include
#define max(a,b) a>b?a:b
int f[105][1005]={0},w[105]={0},p[105]={0},n,m;
int main()
{ int i,j;
//freopen("backpack.in","r",stdin);
//freopen("backpack.out","w",stdout);
scanf("%d%d",&m,&n);
for(i=0;i=w)
f[j]=max(f[i-1][j-w]+p,f[i-1][j]);
else
f[j]=f[i-1][j];
}
printf("%d",f[n][m]);
system("pause");
return 0;
}
/*
200 8
79 83
58 14
86 54
11 79
28 72
62 52
15 48
68 62
334
*/
|