Poj 2663 tri Tiling

Source: Internet
Author: User

Tri Tiling
Time limit:1000 ms   Memory limit:65536 K
Total submissions:7887   Accepted:4134

Description

In how many ways can you tile a 3xn rectangle with 2x1 dominoes?
Here is a sample tiling of a 3x12 rectangle.

Input

Input consists of several test cases followed by a line containing-1. Each test case is a line containing an integer 0 <= n <= 30.

Output

For each test case, output one integer number giving the number of possible tilings.

Sample Input

2812-1

Sample output

31532131

Question: A [I] = 4 * A [I-2]-A [I-4];

#include <iostream>using namespace std;int main(){long long n,a[50];a[0]=1;a[2]=3; for(int i=4;i<=30;i+=2)  a[i]=4*a[i-2]-a[i-4];  while (cin>>n&&n!=-1){if (n%2)cout<<0<<endl;elsecout<<a[n]<<endl;}return 0;}


Poj 2663 tri Tiling

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.