给定 VV 种货币(单位:元),每种货币使用的次数不限。
不同种类的货币,面值可能是相同的。
现在,要你用这 VV 种货币凑出 NN 元钱,请问共有多少种不同的凑法。
输入格式
第一行包含两个整数 VV 和 NN。
接下来的若干行,将一共输出 VV 个整数,每个整数表示一种货币的面值。
输出格式
输出一个整数,表示所求总方案数。
数据范围
1≤V≤251≤V≤25,
1≤N≤100001≤N≤10000
答案保证在long long
范围内。
输入样例:
3 10
1 2 5
输出样例:
10
#include<bits/stdc++.h>
using namespace std;
const int N=10010;
typedef long long ll;
///int v[N],w[N];
ll f[N];
int main()
{
ll n,m;
ll v;
cin>>n>>m;//n种货币,m元
f[0]=1;
for(int i=1;i<=n;i++)
{
cin>>v;
for(int j=v;j<=m;j++)
{
f[j]=f[j]+f[j-v];
}
}
cout<<f[m]<<endl;
return 0;
}