v种货币,求有多少种组成和为n。
dp[i][j]表示前i种货币价格为j有多少种方案,dp[i][j]+=dp[i-1][j-c]。
http://train.usaco.org/usacoprob2?a=jUh88pMwCSQ&S=money
/*
TASK:money
LANG:C++
*/
#include<cstdio>
#include<string>
#include<algorithm>
#define ll long long
#define file(s) freopen(#s".in","r",stdin);freopen(#s".out","w",stdout)
using namespace std;
#define N 10005
int v,n;
ll dp[N]={};
int main(){
file(money);
scanf("%d%d",&v,&n);
int c;
for(int i=;i<=v;i++){
scanf("%d",&c);
for(int j=c;j<=n;j++)
dp[j]+=dp[j-c];
}
printf("%lld\n",dp[n]);
return ;
}