HDOJ(HDU).1284 钱币兑换问题 (DP 完全背包)
题意分析
裸的完全背包问题
代码总览
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define nmax 33000
#define ll long long
using namespace std;
ll dp[nmax];
int coin[3]={1,2,3};
int main()
{
dp[0] = 1;
for(int i =0; i<3; ++i){
for(int j = coin[i]; j<nmax;++j){
dp[j]+=dp[j-coin[i]];
}
}
int N;
while(scanf("%d",&N)!= EOF){
printf("%lld\n",dp[N]);
}
return 0;
}