提交时间:2023-12-16 10:10:41

运行 ID: 116304

#include<bits/stdc++.h> #define int long long using namespace std; int a[1000005],dp[1000005],c[1000005]; signed main(){ int n,w; cin>>n>>w; for (int i = 1;i <= n;i++){ cin>>a[i]; } dp[0] = 1; for (int i = 1;i <= w;i++){ for (int j = 1;j <= n;j++){ dp[i] += dp[i - a[j]]; } } /* for (int i = 1;i <= w;i++){ cout<<dp[i]<<' '; } cout<<'\n'<<dp[w]; */ cout<<dp[w]; return 0; }