#include #include #include #include #include #include #include #define rep(i,n) for(i=0; i> a #define out(a,b) cout << a << b #define print_vec(v) for(auto it=v.begin();it!=v.end();++it)cout<<*it <<" ";cout<9) pop = 'A'+num-10; else pop = '0'+num; str = pop + str; n/=r; } } return str; } int count_string(string str, char c){ int cnt=0, i; rep(i,str.size()){ cnt+=str[i]==c; } return cnt; } void write_vec(int indx, vector &x){ string bin_s=base_conv(indx+1, 2); int cnt=count_string(bin_s, '1'); if(indx-cnt>0&&x[indx-cnt]<0){ x[indx-cnt]=x[indx]+1; write_vec(indx-cnt, x); } if(indx+cnt count(n, -1); count[0]=1; write_vec(0, count); out(count[n-1],endl); return 0; }