01串
时间限制:
1000 ms | 内存限制:
65535 KB
难度:
2
-
ACM的zyc在研究01串,他知道某一01串的长度,但他想知道不含有“11”子串的这种长度的01串共有多少个,他希望你能帮帮他。
注:01串的长度为2时,有3种:00,01,10。
-
第一行有一个整数n(0<n<=100),表示有n组测试数据;随后有n行,每行有一个整数m(2<=m<=40),表示01串的长度;
-
输出不含有“11”子串的这种长度的01串共有多少个,占一行。
-
描述
输入
输出
样例输入
2
2
3
样例输出
3
5
public class Main { /** * @param args */ public static int Facc(int x){ if(x==2) return 3; else if(x==3) return 5; else return Facc(x-1)+Facc(x-2); } public static void main(String[] args) { Scanner cin=new Scanner(System.in); int m=cin.nextInt(); while(m-->0){ int n=cin.nextInt(); System.out.println(Facc(n)); } } }