HDU1028 - Ignatius and the Princess III

Posted oeong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU1028 - Ignatius and the Princess III相关的知识,希望对你有一定的参考价值。

这是道完全背包问题,一共有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;
}

以上是关于HDU1028 - Ignatius and the Princess III的主要内容,如果未能解决你的问题,请参考以下文章