codevs——1065 01字符串

时间:2023-03-10 08:08:55
codevs——1065 01字符串

1065 01字符串

 时间限制: 1 s
 空间限制: 128000 KB
 题目等级 : 黄金 Gold
题目描述 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);
}