提交时间:2023-12-12 13:52:04
运行 ID: 115608
#include<bits/stdc++.h> using namespace std; int n,m,ans; int a[1005]; int dfs(int x){ // cout<<x<<endl; if(x==m)return ans++,0; for(int i=1;i<=n;i++){ if(x+a[i]<=m)dfs(x+a[i]); else break; } } int main(){ cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; dfs(0); return cout<<ans,0; }