Hdu-2501-tiling_easy version (simple recursive relationship!!) )

Source: Internet
Author: User

Tiling_easy versionTime limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 5516 Accepted Submission (s): 4347


Problem description has a grid size of 2 x N and now requires 2 sizes of dominoes to be paved, and the domino specifications are 2 x 1 and 2 x 2, please calculate how many kinds of paving methods there are.

The first line of input inputs 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), indicating that the size of the grid is 2 rows N columns.

The output output has a total number of paving methods, one row for each set of data.

Sample Input
32812

Sample Output
31712731

Source "ACM Program Design" Short Semester exam _ software engineering and other major



idea: recursion, formula for a[n] = a[n-1] + 2*a[n-2];


AC Code:




Hdu-2501-tiling_easy version (simple recursive relationship!!) )

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.