0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-14 21:58:48 +00:00
OI-codes/Luogu/P2404/P2404.cpp

29 lines
489 B
C++
Raw Normal View History

#include <bits/stdc++.h>
using namespace std;
int n, a[10];
void dfs(int x, int depth, int last) {
if (x > n) return;
if (x == n) {
2021-11-19 09:01:13 +00:00
for (int i = 1; i < depth - 1; i++) {
cout << a[i] << '+';
}
2021-11-19 09:01:13 +00:00
cout << a[depth - 1] << endl;
return;
}
for (int i = last; i < n; i++) {
a[depth] = i;
dfs(x + i, depth + 1, i);
a[depth] = 0;
}
return;
}
int main() {
cin >> n;
dfs(0, 1, 1);
return 0;
}