#include #include #include #include using namespace std; using dp_t=map; using dp2_t=map>; using p_t=vector; void solve_r(dp_t& dp, p_t& p, int f, int s, int i, int n) { dp[f]=s; if(ifirst, it->second); } printf("--- dpt ---\n"); for(auto it=dpt.begin();it!=dpt.end();++it) { printf("s=%d ", it->first); for(auto f: it->second) { printf(" f=%08x", f); } printf("\n"); } */ for(auto it=dph.rbegin();it!=dph.rend();++it) { int hf, hs, tf, f; hf=it->first; hs=it->second; if(dpt.find(s-hs)!=dpt.end()) { vector& v=dpt[s-hs]; for(auto it=v.rbegin();it!=v.rend();++it) { tf=*it; f=hf|tf; // printf("f=%08x\n", f); int nc=0; for(i=0;i>(n-1-i))&1) printf("%s%d", nc++?" ":"", i+1); } printf("\n"); } } } } } return 0; }