#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int dp[1000];
int a[100];
int main()
{
int n,sum;
while(~scanf("%d%d",&n,&sum))
{
for(int i = 1;i <= n;i++)
scanf("%d",&a[i]);
memset(dp,0,sizeof(dp));
dp[0] = 1;
for(int i = 1;i <= n;i++)
{
for(int j = sum;j >= a[i];j--)
{
if(dp[j-a[i]])
{
dp[j] += dp[j-a[i]] ;
}
}
}
cout<<dp[sum]<<endl;
}
}
01背包之(数之组合)
最新推荐文章于 2024-02-23 23:31:21 发布