Files
python/TangDou/XiTi/1314.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

32 lines
587 B
C++

#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++) {
cout << path[i];
if (i < path.size() - 1) cout << "+";
}
cout << endl;
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 n;
cin >> n;
dfs(n);
cout << "total=" << cnt << endl;
return 0;
}