P1474 [USACO2.3]Money System / [USACO07OCT]Cow Cash G

[Aimee](https://www.luogu.com.cn/problem/P1474)

显然是个背包

#include<iostream>
#include<cstdio>
#define int long long
using namespace std;
int n,v;
int f[100001];
int znx[1000001];
signed main(){
	scanf("%d%d",&n,&v);
	for(int i=1;i<=n;++i)
		scanf("%d",&znx[i]);
	f[0]=1;
	for(int j=1;j<=n;++j)	{
		for(int i=1;i<=v;++i){
			if(znx[j]<=i){
				f[i]+=f[i-znx[j]];
			}
		} 
	//	cout<<f[i]<<" ";
	}
	cout<<f[v];
	return 0;
}
posted @ 2021-02-24 10:34  Simex  阅读(50)  评论(0编辑  收藏  举报