Title Link: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1031
Test instructions: Chinese question eh ~
Idea: For the case of the X-block Domino, we use a[x] to express its method number, which is more than the x-1 block Domino, a domino, there are two kinds of dominoes to put the method:
1. We can directly add it vertically at the end, then the number of permutations is the first x-1 block of the number of dominoes, that is, a[x-1];
2. We can also put it sideways with the preceding piece of dominoes, then the number of permutations is the number of the first x-2 block dominoes, that is, a[x-2];
So there are a[x]=a[x-1]+a[x-2];
Code:
1#include <bits/stdc++.h>2 #defineMAXN 10103 using namespacestd;4 5 Const intmod=1e9+7;6 7 intMainvoid){8 intA[MAXN], N;9a[0]=1, a[1]=1;TenCIN >>N; One for(intI=2; i<=n; i++){ AA[i]= (a[i-1]+a[i-2])%MoD; - } -cout << A[n] <<Endl; the return 0; -}
51nod1031 (simple Fibonacci sequence)