#include <stdio.h>
#define DIM 100
int stack[DIM],
N,
level,
s;
void init(){
if(level == 1) {
stack[level] = 0;
} else {
stack[level] = stack[level-1] - 1;
}
}
int succ() {
if(stack[level] < N - s) {
stack[level]++;
return 1;
} else {
s -= stack[level-1];
return 0;
}
}
int valid() {
if(stack[level] <= N - s) {
s = s + stack[level];
return 1;
}
return 0;
}
void print() {
//converted to string
char out[10];
int k = 0;
for(int i = 1; i <= level;i++) {
out[k++] = stack[i] + '0';
out[k++] = '+';
}
out[--k] = '\0';
s -= stack[level];
}
int sol() {
return s == N;
}
void bk() {
level = 1;
init();
while(level > 0) {
int hs = 1, iv = 0;
while(hs && !iv) {
hs = succ();
if(hs) {
iv = valid();
}
}
if(hs) {
if(sol()) print();
else {
level++;
init();
}
} else {
level--;
}
}
}
int main(int argc, char const *argv[]) {
;
bk()
;
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgRElNIDEwMAoKaW50IHN0YWNrW0RJTV0sCiAgICBOLAogICAgbGV2ZWwsCiAgICBzOwoKdm9pZCBpbml0KCl7CiAgICAgaWYobGV2ZWwgPT0gMSkgewogICAgICAgc3RhY2tbbGV2ZWxdID0gMDsKICAgICB9IGVsc2UgewogICAgICAgc3RhY2tbbGV2ZWxdID0gc3RhY2tbbGV2ZWwtMV0gLSAxOwogICAgIH0KfQoKaW50IHN1Y2MoKSB7CiAgICBpZihzdGFja1tsZXZlbF0gPCBOIC0gcykgewogICAgICAgc3RhY2tbbGV2ZWxdKys7CiAgICAgICByZXR1cm4gMTsKICAgIH0gZWxzZSB7CiAgICAgICBzIC09IHN0YWNrW2xldmVsLTFdOwogICAgICAgcmV0dXJuIDA7CiAgICB9Cn0KCmludCB2YWxpZCgpIHsKCiAgICBpZihzdGFja1tsZXZlbF0gPD0gTiAtIHMpIHsKICAgICAgIHMgPSBzICsgc3RhY2tbbGV2ZWxdOwogICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICByZXR1cm4gMDsKfQoKdm9pZCBwcmludCgpIHsKICAgICAvL2NvbnZlcnRlZCB0byBzdHJpbmcKICAgICBjaGFyIG91dFsxMF07CiAgICAgICAgICBpbnQgayA9IDA7CiAgICAgICAgICBmb3IoaW50IGkgPSAxOyBpIDw9IGxldmVsO2krKykgewogICAgICAgICAgICAgIG91dFtrKytdID0gc3RhY2tbaV0gKyAnMCc7CiAgICAgICAgICAgICAgb3V0W2srK10gPSAnKyc7CiAgICAgICAgICB9CiAgICAgICAgICBvdXRbLS1rXSA9ICdcMCc7CiAgICAgICAgICBzIC09IHN0YWNrW2xldmVsXTsKICAgICAgICAgIHByaW50ZigiJXMiLCBvdXQpOwogICAgIHByaW50ZigiXG4iKTsKfQoKaW50IHNvbCgpIHsKICAgIHJldHVybiBzID09IE47Cn0KCnZvaWQgYmsoKSB7CiAgICAgbGV2ZWwgPSAxOwogICAgIGluaXQoKTsKCiAgICAgd2hpbGUobGV2ZWwgPiAwKSB7CiAgICAgICAgICBpbnQgaHMgPSAxLCBpdiA9IDA7CiAgICAgICAgICB3aGlsZShocyAmJiAhaXYpIHsKICAgICAgICAgICAgICAgIGhzID0gc3VjYygpOwogICAgICAgICAgICAgICAgaWYoaHMpIHsKICAgICAgICAgICAgICAgICAgaXYgPSB2YWxpZCgpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgfQogICAgICAgICAgaWYoaHMpIHsKICAgICAgICAgICAgaWYoc29sKCkpIHByaW50KCk7CiAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgIGxldmVsKys7CiAgICAgICAgICAgICAgICAgaW5pdCgpOwogICAgICAgICAgICAgICB9CiAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBsZXZlbC0tOwogICAgICAgICAgfQogICAgIH0KfQoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgY29uc3QgKmFyZ3ZbXSkgewogIHNjYW5mKCIlZCIsICZOKTsKICA7CiAgYmsoKQogIDsKICByZXR1cm4gMDsKfQo=