
题目描述 Description
输出仅有0和1组成的长度为n的字符串,并且其中不能含有3个连续的相同子串。
输入描述 Input Description
输入文件只有一行一个整数n,表示有0和1组成的字符串的长度。0<=n<=30。
输出描述 Output Description
输出文件只有一行一个整数,表示所有满足条件的字符串的个数。
样例输入 Sample Input
1
样例输出 Sample Output
2
#include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int n,ans; int read() { ,f=; char ch=getchar(); ; ch=getchar();} +ch-'; ch=getchar();} return x*f; } void dfs(int now,int s,int l) { if(l==n) {ans++;return ;} ) dfs(now,s+,l+); dfs(now^,,l+); } int main() { n=read(); ) ans=; ,,),dfs(,,); printf("%d",ans); }