#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; void solve(const vector& a, vector >& v) { int n = a.size(); v.resize(1 << n); for(int i=0; i<(1< bs(i); int sum = 0; for(int j=0; j> n >> s; vector v(n); for(int i=0; i> v[i]; reverse(v.begin(), v.end()); vector a(n/2), b((n+1)/2); for(int i=0; i > x, y; solve(a, x); solve(b, y); sort(x.begin(), x.end()); sort(y.rbegin(), y.rend()); unsigned j = 0; vector ret; for(unsigned i=0; i 0 && x[i].first + y[j-1].first == s) -- j; while(j < y.size() && x[i].first + y[j].first >= s){ if(x[i].first + y[j].first == s) ret.push_back(x[i].second | (y[j].second << (n / 2))); ++ j; } } sort(ret.rbegin(), ret.rend()); for(unsigned i=0; i bs(ret[i]); bool isFirst = true; for(int j=n-1; j>=0; --j){ if(bs[j]){ if(isFirst) isFirst = false; else cout << ' '; cout << (n - j); } } cout << endl; } return 0; }