提交时间:2023-12-09 09:29:30
运行 ID: 114791
#include <bits/stdc++.h> using namespace std; int dp[305]; int coin[5005]; int main() { int n , m; cin >> n >> m; for(int i = 1;i <= n;i++) cin >> coin[i]; dp[0] = 1; for(int i = 1;i <= n;i++) { for(int j = 1;j <= m;j++) { if(j >= coin[i - 1]) dp[j] += dp[j - coin[i]]; } } cout << dp[m]; return 0; }