提交时间:2023-12-13 13:16:31
运行 ID: 115739
#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; }