money.cpp

来自「USACO chapter two.Useful for beginners.」· C++ 代码 · 共 25 行

CPP
25
字号
/*
ID: chenkai4
PROG: money
LANG: C++
*/
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("money.in");
ofstream out("money.out");
long long int f[10001];
int coin[26],V,N;
int main()
{
	in>>V>>N;
	for(int a=1;a<=V;a++)
		in>>coin[a];
	f[0]=1;
	for(int a=1;a<=V;a++)
		for(int b=1;b<=N;b++)
			if(coin[a]<=b) 
				f[b]+=f[b-coin[a]];
	out<<f[N]<<endl;
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?