HDU1284(完全揹包)

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
using namespace std;
int dp[33333] = {0};
int main()
{
    int n;
    dp[0] = 1;
    for(int i = 1; i <= 3; i++)
    {
        for(int j = i; j <= 33332; j++)
        {
            dp[j] += dp[j-i];
        }
    }
    while(scanf("%d", &n) == 1)
    {
        printf("%d\n", dp[n]);
    }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章