提交时间:2023-12-09 09:43:32
运行 ID: 114806
#include<iostream> using namespace std; const int N = 5010, M = 310; long long f[N], a[M], m, n; int main(){ cin >> m >> n; for(int i = 1; i <= m; i++){ cin >> a[i]; } f[0] = 1; for(int i = 1; i <= m; i++){ for(int j = 1; j <= n; j++){ if(j - a[i] >= 0) f[j] += f[j - a[i]]; } } cout << f[n]; return 0; }