题目连接https://www.luogu.org/problemnew/show/P1060
#include<bits/stdc++.h>
using namespace std;
int a[105];
int dp[10009];
int main()
{
//freopen("t.txt","r",stdin);
int n,m;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
memset(dp,0,sizeof(dp));
dp[0]=1;
int tot=0;
for(int i=0;i<n;i++)
{
for(int j=tot;j>=0;j--)
{
if(j+a[i]<=m&&dp[j])
{
dp[j+a[i]]+=dp[j];
}
}
tot+=a[i];
if(tot>m)
tot=m;
}
printf("%d",dp[m]);
return 0;
}