货币系统 Money Systems

[Time Gate]

https://www.luogu.org/problemnew/show/P1474

【解题思路】

一道水到不能再水的01背包模板题

思路显然,上简洁代码

【code】

 1 #include<cstdio>
 2 #include<iostream>
 3 using namespace std;
 4 typedef long long LL;
 5 LL i,j,v,n,c,f[10005];
 6 int main(){
 7     //freopen("money.in","r",stdin);
 8     //freopen("money.out","w",stdout);
 9     cin>>v>>n;
10     f[0]=1;
11     for(i=1;i<=v;i++){
12         cin>>c;
13         for(j=c;j<=n;j++)
14             f[j]+=f[j-c];
15     }
16     cout<<f[n]<<endl;
17     return 0;
18 }

 

posted @ 2019-07-15 12:31  GTR_PaulFrank  阅读(189)  评论(0)    收藏  举报