方程很简单

f[0] = 1

f[j] += f[j-w[i]]

#include<cstdio>
#define REP(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

const int MAXM = 11234;
const int MAXN = 112;
int f[MAXM], w[MAXN];
int m, n;

int main()
{
	scanf("%d%d", &n, &m);
	REP(i, 0, n) scanf("%d", &w[i]);
	
	f[0] = 1;
	REP(i, 0, n)
		for(int j = m; j >= w[i]; j--)
			f[j] += f[j-w[i]];
	printf("%d\n", f[m]);
	
	return 0;
}

 

相关文章:

  • 2022-12-23
  • 2021-08-05
  • 2022-02-17
  • 2022-02-14
  • 2021-08-01
  • 2021-07-05
猜你喜欢
  • 2021-06-13
  • 2021-06-17
  • 2022-12-23
  • 2021-12-09
  • 2020-05-18
  • 2021-09-23
  • 2021-12-19
相关资源
相似解决方案