题目描述:
主要思路:
class Solution {
public:
int numTilings(int n) {
long long f[n][4],mod=1e9+7;
f[0][0]=1;
f[0][1]=f[0][2]=0;
f[0][3]=1;
for(int i=1;i<n;++i)
{
f[i][0]=f[i-1][3];
f[i][1] = (f[i-1][0]+f[i-1][2])%mod;
f[i][2] = (f[i-1][0]+f[i-1][1])%mod;
f[i][3] = (f[i-1][0]+f[i-1][1]+f[i-1][2]+f[i-1][3])%mod;
}
return f[n-1][3];
}
};