hdu1284经典钱币兑换问题

钱币兑换问题。

题目 http://acm.hdu.edu.cn/showproblem.php?pid=1284

完全背包。

这种是求背包问题最多的组合方案

参考了一些资料   http://blog.csdn.net/wumuzi520/article/details/7021210




#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;

int dp[32768];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int i,j;
        memset(dp,0,sizeof(dp));
        dp[0]=1;
        for(i=1;i<=3;i++)
        {
            for(j=i;j<=n;j++)
            {
				if (j>=i)
                dp[j]=dp[j]+dp[j-i];
            }
        }
        cout<<dp[n]<<endl;
    }
    return 0;
}



原文地址:https://www.cnblogs.com/riasky/p/3431134.html