1504071639-hd-tiling_easy version

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.