完全背包
选法并不会重复,
因为是每个单独,只用一次
class Solution { public: int dp[5100]; int change(int amount, vector<int>& coins) { memset(dp, 0, sizeof(dp)); dp[0] = 1; for(int i = 1; i <= coins.size(); i++) { int coin = coins[i - 1]; for(int j = coin; j <= amount; j++) { dp[j] += dp[j - coin]; } } return dp[amount]; } };