//这个是求解的,复杂度应该是解空间的大小
void out(int ary[], int n)
{
for (int i = 0; i < n; i++) {
printf("%d ", ary[i]);
}
printf("\n");
}
bool kubi(int sum, int ary[], int max, int level = 0)
{
bool flag = false;
if (max >= sum) {
ary[level] = sum;
out(ary, level + 1);
flag = true;
max = sum - 1;
}
for (int i = max; i > 0; i--) {
ary[level] = i;
if (kubi(sum - i, ary, i - 1, level + 1))
flag = true;
else
break;
}
return flag;
}