各种背包
1 int dp[N]; 2 void OneZeroPack( int v , int c , int w ){//01背包 3 for( int i = v ; i >= c ; i-- ) 4 dp[i] = max( dp[i] , dp[i-c] +w ) ; 5 } 6 void CompletePack( int v , int c , int w ){//完全背包 7 for( int i = c ; i <= v ; i++ ) 8 dp[i] = max( dp[i] , dp[i-c] +w ) ; 9 } 10 void MultipliePack( int v , int c, int w , int n){//多重背包 11 if( n*c >= v ){ 12 CompletePack( v , c , w ) ; 13 return ; 14 } 15 int k = 1 ; 16 while( k < n ){ 17 OneZeroPack( v , k*c , k*w ) ; 18 n -= k ; 19 k <<= 1 ; 20 } 21 OneZeroPack( v , n*c , n*w ) ; 22 }