2Description
今天的问题是这样的:用n个2X1的矩形(这种矩形我们以后称之为骨牌或多米诺)覆盖2Xn的棋盘,有多少种不同的覆盖法?
Input
输入只有一行n(意义如上所述,1<=n<=45)。
Output
输出也只有一行,即覆盖的方法种数。
Sample Input
2
Sample Output
2
#include <bits/stdc++.h>
using namespace std;
long long a[50];
int main()
{
a[1]=1;
a[2]=2;
for(int i=3;i<=45;i++)
{
a[i]=a[i-1]+a[i-2];
}
int n;
while(cin>>n)
{
cout<<a[n]<<endl;
}
return 0;
}

2036

被折叠的 条评论
为什么被折叠?



