Link to the original question: https://vjudge.net/contest/331993#problem/B
In a rectangular grid of 2 * N, with a 1 * 2 domino filled squares.
Q. How many different methods of arrangement.
For example: 2 * 3 grid, a total of three different discharge methods. (Due to the large number of programs, only the output Mod 10 ^ 9 + 7) is
Input Input N (N <= 1000) Output Output Number 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; }