挺有意思的dp 思维题,比较简单直接看代码就行。
```//
// Created by acer on 2021/5/11.
//
#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
#define int long long
int dp[11000][2][2];
int num[11000];
int ans[1100];
signed main() {
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> num[i];
}
if (num[1] == 1)
{
dp[1][1][0] = dp[1][0][1] = 1;
} else if (num[1] == 2)
{
dp[1][1][1] = 1;
} else
{
dp[1][0][0] = 1;
}
for (int j = 2; j < n; ++j) {
if (num[j] == 1)
{
dp[j][1][0] += dp[j-1][0][1];
dp[j][0][1] += dp[j-1][0][0];
dp[j][0][0] += dp[j-1][1][0];
}
else if (num[j] == 2)
{
dp[j][1][1] += dp[j-1][0][1];
dp[j][1][0] += dp[j-1][1][1];
dp[j][0][1] += dp[j-1][1][0];
}
else if (num[j] == 3)
{
dp[j][1][1] += dp[j-1][1][1];
} else {
dp[j][0][0] += dp[j-1][0][0];
}
}
if (num[n] == 1)
{
cout << dp[n-1][0][1] + dp[n-1][1][0];
} else if (num[n] == 2)
{
cout << dp[n-1][0][1] + dp[n-1][1][0]+dp[n-1][1][1];
} else{
cout << dp[n-1][0][0];
}
}
//
//0 0
//1 1 1