HDU1028

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028

这是道完全背包问题,一共有N个数,且每个数可重复。

#include <bits/stdc++.h>
using namespace std;
int main() {
    int n = 120;
    int dp[121] = {1};
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            dp[j] += dp[j-i];
        }
    }
    while (cin >> n) {
        cout << dp[n] << endl;
    }
    return 0;
}
原文地址:https://www.cnblogs.com/oeong/p/12043822.html