Tiling_easy version
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 5910 Accepted Submission (s): 4646
problem Descriptionthere is a grid of size 2 x N, which now needs to be paved with 2 sizes of dominoes, 2 x 1 and 2 x 2 for the Domino specifications, please calculate how many methods of laying are in total.
Inputthe first line of the input contains a positive integer t (t<=20), representing a total of T-group data, followed by a T-row of data, each containing a positive integer n (n<=30), which indicates that the size of the grid is 2 rows N columns.
OutputOutput a total of how many methods of laying, the output of each group of data to occupy one row.
Sample Input
32812
Sample Output
31712731
Thinking of solving problemsfor this kind of math problem, there will be a formula to find out the answer. Well, forgive me, little white, not to come out of the formula, refer to the online code of the great God to find this formula, like the great God salute. Code
#include <iostream>int num[32];using namespace Std;int main () {int n;int m;int i,j,k;int sum;num[1]=1;num[2]=3;for (i=3;i<=30;i++) Num[i]=num[i-1]+2*num[i-2];cin>>n;while (n--) {Cin>>m;cout<<num[m]<<endl;} return 0;}
1504071639-hd-tiling_easy version