Statistical issues
Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 6413 Accepted Submission (s): 3787
Problem Description in an infinitely large two-dimensional plane, we make the following assumptions:
1, can only move one grid at a time;
2, can not go backwards (assuming your destination is "up", then you can go to the left, you can go to the right, you can go up, but not down);
3, through the lattice immediately collapsed can not go again the second time;
The number of different schemes for N-Steps (2 methods are considered different if one step is not the same).
Input first gives a positive integer c, which indicates that there is a C set of test data
In the next line of C, each line contains an integer n (n<=20), which indicates that you want to walk n steps.
Output Please program the total number of different programs to go n steps;
One row for each set of outputs.
Sample Input
2 1 2
Sample Output
3 7 in the beginning unexpectedly want to use DFS to beg, finally found stupid home, Khan = =. Push a Table AC code:
#include <stdio.h>
int num[25];
void block ()
{
num[0]=1;
num[1]=3;
for (int i=2;i<=20;i++)
{
num[i]=num[i-1]*2+num[i-2];
}
}
int main ()
{
block ();
int n,t;
scanf ("%d", &t);
while (t--)
{
scanf ("%d", &n);
printf ("%d\n", Num[n]);
}
return 0;
}