#include #include #include #include #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define li long long int #define rep(i,to) for(li i=0;i<((li)(to));i++) #define repp(i,start,to) for(li i=(li)(start);i<((li)(to));i++) #define pb push_back #define sz(v) ((li)(v).size()) #define bgn(v) ((v).begin()) #define eend(v) ((v).end()) #define allof(v) (v).begin(), (v).end() #define dodp(v,n) memset(v,(li)n,sizeof(v)) #define bit(n) (1ll<<(li)(n)) #define mp(a,b) make_pair(a,b) #define rin rep(i,n) #define EPS 1e-10 #define ETOL 1e-8 #define MOD 1000000007 #define F first #define S second #define endl "\n" #define pp(X) cout<0)res+=bit(n-i-1); } x=res; } int main(){ ios::sync_with_stdio(false); li n, s; cin>>n>>s; rin{cin>>p[i];} if(n==1){ if(p[0]==s)puts("1"); return 0; } li mid=n/2; multimap sum1, sum2; rep(i,bit(mid)){ li sum=0; rep(j,mid){ if(((1ll<0)sum+=p[j]; } sum1.insert(mp(sum,i)); } rep(i,bit(n-mid)){ li sum=0; rep(j,n-mid){ if(((1ll<0)sum+=p[j+mid]; } sum2.insert(mp(s-sum,i)); } //for(map::iterator it=sum1.begin(); it!=sum1.end(); ++it)pp((*it)); //for(map::iterator it=sum2.begin(); it!=sum2.end(); ++it){cout<<"--- "; pp((*it));} vector
  • res; for(multimap::iterator it=sum1.begin(); it!=sum1.end(); ++it){ multimap::iterator it2=sum2.lower_bound(it->F); while(it2!=sum2.end() && it2->F==it->F){ //p2(it->F, it2->F); res.pb((it2->S<S); ++it2; } } rep(i,sz(res))reverse_bit(res[i], n); sort(allof(res)); reverse(allof(res)); rep(i,sz(res)){ rep(j,n)if((bit(n-1-j)&res[i])>0)cout<