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