AcWing 3195. 有趣的数
原题链接
中等
作者:
tzp2333
,
2021-02-20 22:40:19
,
所有人可见
,
阅读 333
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int mod = 1e9+7,N=1010;
int f[N][16];
int main()
{
int n;cin>>n;
f[1][1<<2] = 1;f[1][1<<1] = 1;f[1][1<<3] = 1;
for (int i = 2;i<=n;i++)
{
for (int j = 1;j<=15;j++)
{
for (int k = 0;k<4;k++)
{
if (k==2&&(j>>3 & 1)) continue;
if (k==0&&(j>>1 & 1)) continue;
f[i][j | (1<<k)] = (f[i][j | (1<<k)] +f[i-1][j]) % mod;
}
}
}
cout<<f[n][15];
return 0;
}