#include #include using namespace std; void all_partitions(int n, int n_max, vector &a) { if (n == 0) { for (auto v : a) { cout << v << " "; } cout << endl; return; } for (int v = 1; v <= n_max; v++) { a.push_back(v); all_partitions(n - v, min(n - v, v), a); a.pop_back(); } } void all_partitions(int n) { vector a; all_partitions(n, n, a); } int main(void) { int n; cin >> n; all_partitions(n); return 0; }