01 String time limit:MS | Memory limit:65535 KB Difficulty:2
-
Describe
-
ACM's ZYC is studying 01 strings, and he knows the length of some 101 strings, but he wants to know how many 01 strings of this length do not contain the "11" substring, and he wants you to help him.
Note: The length of the 01 string is 2 o'clock, there are 3 kinds: 00,01,10.
-
-
Input
-
-
the first line has an integer n (0<n<=100), which indicates that there are n sets of test data;
Then there are n rows, each line having an integer m (2<=m<=40), representing the length of the 01 string;
-
-
Output
-
The
-
output does not contain the "11" substring of this length of 01 string total number of, one row.
-
-
Sample input
-
-
223
-
-
Sample output
-
35
1#include <iostream>2 using namespacestd;3 inta[ -];4 intMain ()5 {6a[0]=1, a[1]=2; a[2]=3;7 for(intI=3; i<= -; i++)8a[i]=a[i-1]+a[i-2];9 intN,n;cin>>N;Ten while(n--) One { ACin>>N; -cout<<a[n]<<Endl; - } the return 0; -}
Nyoj 252 01 strings (Fibonacci sequence variants)