解题思路:双递归,构建一个类似二叉树的结构,左子树+1,右子树+2
注意事项:
参考代码:
#include <iostream>
#include <deque>
#include <string>
#include <iterator>
#include <vector>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string.h>
using namespace std;
int ans;
int n;
void dfs(int a)
{
if(a>n)
return ;
if(a==n)
{
ans++;
return ;
}
dfs(a+1);
dfs(a+2);
}
int main()
{
cin>>n;
dfs(0);
cout<<ans<<endl;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:562 |
点我有惊喜!你懂得!浏览:1671 |
C语言训练-求具有abcd=(ab+cd)2性质的四位数 (C语言代码)浏览:1372 |
Tom数 (C++代码)浏览:828 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:638 |
C语言训练-数字母 (C语言代码)浏览:649 |
剪刀石头布 (C语言代码)浏览:1755 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:695 |
字符逆序 (C语言代码)浏览:621 |
班级人数 (C语言代码)浏览:927 |