01背包-近似算法
最后更新于:2022-04-01 20:31:05
~~~
void dp2(int *w, int *v, int n, int c){cout<<"dp2:"<0;i--){
if(m[n][i]<=c&&m[n][i]!=-1){
maxV = i;
break;
}
}
for(int i=n;i>0;i--){
if(m[i][maxV]==m[i-1][maxV]) x[i] = 0;
else {
x[i] = 1;
maxV -= v[i-1];
}
}
// for (int i = 1; i <= n; i++) cout << x[i] << "\t";
cout << endl;
}
void adp(int *w, int *v, int n, int c,int e){cout<<"adp:"<
';