题目:

###该题主要考察递推、递归
将该题看成若干个子问题

#include<bits/stdc++.h>
using namespace std;
const int N=20;
int a[N];
int dfs(int dep){
  int res=1;
  for(int i=1;i<=a[dep-1]/2;++i){
    a[dep]=i;
    res+=dfs(dep+1);
  }
  return res;
}
int main(){
  int n;cin>>n;
  a[1]=n;
  cout<<dfs(2)<<'\n';
  return 0;
}
整体思路:
- 开设一个数组存放数字,第一个数字永远为n,所以设为n
- 从dep搜索深度2开始逐层搜索,将该层的数字实时转换为i,数字个数res每次都要加上下一层的符合条件的数字个数,输出返回的数字个数res即可
###如果还是不明白可以拿张纸自己推一下,每个当前层必定确定有一个数,画出来的图有多少个节点就有多少种可能,每层有多少个节点,在该搜索深度就循环了多少次





![[c++] c++ 中的顺序(构造,析构,初始化列表,继承)](https://img-blog.csdnimg.cn/direct/839bf38b9a014664b66372bed6ef34a6.png)













