codeup27991 骨牌铺法
时空限制 1000ms/128MB
题目描述
在2*n的一个长方形方格,用一个1*2的骨牌铺满方格。
编写一个程序,试对给出的任意一个n,输出铺法总数。
输入
输入一个正整数n,表示长方形方格的规格是2×n (0<n<=50)。
输出
请输出铺放方案的总数。
样例输入
3
样例输出
3
代码
#include<iostream>
using namespace std;
const int N = 55;
long long a[N];
int main(){
int n;
a[1]=1LL; a[2]=2LL;
for (int i=3; i<55; i++)
a[i]=a[i-2]+a[i-1];
while (cin>>n)
cout<<a[n]<<endl;
return 0;
}