'commit'
This commit is contained in:
31
TangDou/XiTi/1314.cpp
Normal file
31
TangDou/XiTi/1314.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user