01 StringsTime limit: Ms | Memory limit: 65535 KB Difficulty: 2 description
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. The input 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; The output output does not contain a "11" substring of this length of 01 string total number, one row. Sample input
2
2
3
Sample output
3
5
/*
DP generally by copy ...
time:2014-8-28 1:52
*/
#include
<cstdio> #include <cstring>
int dp[100];
void Getdp () {
dp[2]=3;dp[3]=5;
for (int i=4;i<=41;i++)
dp[i]=dp[i-1]+dp[i-2];
}
void Solve () {
int T;
Memset (Dp,0,sizeof (DP));
GETDP ();
scanf ("%d", &t);
while (t--) {
int N;
scanf ("%d", &n);
printf ("%d\n", Dp[n]);
}
}
int main () {
solve ();
return 0;
}