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.
34 lines
582 B
34 lines
582 B
2 years ago
|
#include <bits/stdc++.h>
|
||
|
|
||
|
using namespace std;
|
||
|
vector<int> a;
|
||
|
int m;
|
||
|
int cnt;
|
||
|
|
||
|
/**
|
||
|
* 功能:整数的拆分
|
||
|
* @param n 要拆分的数
|
||
|
*/
|
||
|
void dfs(int n) {
|
||
|
if (n == 0 && a.size() > 1) {
|
||
|
for (int i = 0; i < a.size(); i++) printf("%d ", a[i]);
|
||
|
printf("\n");
|
||
|
cnt++;
|
||
|
return;
|
||
|
}
|
||
|
// a 2 3 4 ->5 6 7
|
||
|
for (int i = a.size() == 0 ? 1 : a[a.size() - 1]; i <= n; i++) {
|
||
|
a.push_back(i);
|
||
|
dfs(n - i);
|
||
|
a.pop_back();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main() {
|
||
|
cin >> m;
|
||
|
dfs(m);
|
||
|
//总数量
|
||
|
printf("%d ", cnt);
|
||
|
return 0;
|
||
|
}
|