You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
589 B
29 lines
589 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int cnt;
|
|
vector<int> path;
|
|
void dfs(int n) {
|
|
if (n == 0) {
|
|
for (int i = 0; i < path.size(); i++) {
|
|
printf("%d", path[i]);
|
|
if (i < path.size() - 1) printf("+");
|
|
}
|
|
printf("\n");
|
|
cnt++;
|
|
return;
|
|
}
|
|
for (int i = path.empty() ? 1 : path.back();
|
|
i <= n; i++) {
|
|
path.push_back(i);
|
|
dfs(n - i);
|
|
path.pop_back();
|
|
}
|
|
}
|
|
int main() {
|
|
int x;
|
|
cin >> x;
|
|
dfs(x);
|
|
printf("total = %d", cnt);
|
|
return 0;
|
|
} |