代码如下:
#include<bits/stdc++.h>
using namespace std;
const int N=20;
int a[N];//作为临时数组,dfs搜索–>枚举当前层数搜索的数 会用到
int dfs(int depth)//按深度进行搜索
{
int answer=1;//默认输入的数为第一层
//带0的数不算做答案(如0136=136)
for(int i=1;i<=a[depth-1]/2;i++)//枚举当前层数搜索的数
{
a[depth]=i;
answer+=dfs(depth+1);
}
return answer;//每次搜索结束都返回answer
}
int main()
{
int n;cin>>n;
a[1]=n;//第一层已知 不用搜索
cout<<dfs(2)<<"\n";//dfs参数为层数 从第二层开始搜索
return 0;
}