33 lines
496 B
C++
33 lines
496 B
C++
#include <iostream>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
vector<int> path;
|
|
|
|
void dfs(int rest, int start) {
|
|
for(int i = start; i <= rest / 2; i++) {
|
|
|
|
path.push_back(i);
|
|
|
|
// 输出当前方案
|
|
for(int j = 0; j < path.size(); j++) {
|
|
cout << path[j] << "+";
|
|
}
|
|
cout << rest - i << endl;
|
|
|
|
// 继续拆
|
|
dfs(rest - i, i);
|
|
|
|
path.pop_back();
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int n;
|
|
cin >> n;
|
|
|
|
dfs(n, 1);
|
|
|
|
return 0;
|
|
} |