vjudge 骨牌覆盖

原题链接:https://vjudge.net/contest/331993#problem/B

在2*N的一个长方形方格中,用一个1*2的骨牌排满方格。

问有多少种不同的排列方法。

例如:2 * 3的方格,共有3种不同的排法。(由于方案的数量巨大,只输出 Mod 10^9 + 7 的结果)

Input输入N(N <= 1000)Output输出数量 Mod 10^9 + 7Sample Input

3

Sample Output

3


#include<bits/stdc++.h>
using namespace std;
int a[10005];
const int mod=1e9+7;
int main(){
    a[1]=1,a[2]=2;
    int n;
    cin>>n;
    for(int i=3;i<=n;i++){
        a[i]=(a[i-1]+a[i-2])%mod;
    }
    cout<<a[n];
    return 0;
}


猜你喜欢

转载自www.cnblogs.com/QingyuYYYYY/p/11628161.html