提交时间:2024-02-21 19:56:27

运行 ID: 41599

#include <bits/stdc++.h> using namespace std; int w[25] , f[1005]; int main(){ int n,t; cin >> n >> t; for(int i = 1; i <= n; i++){ cin >> w[i]; } f[0] = 1; for(int i = 1; i <= n; i++){ for(int j = t; j >= w[i]; j--){ f[j] = f[j] + f[j - w[i]]; } } cout << f[t] << endl; return 0; }