小蓝现在有一个长度为100的数组,数组中的每个元素的值都在0 到9 的范围之内。数组中的元素从左至右如下所示
5 6 8 6 9 1 6 1 2 4 9 1 9 8 2 3 6 4 7 7 5 9 5 0 3 8 7 5 8 1 5 8 6 1 8 3 0 3 7 9 2 7 0 5 8 8 5 7 0 9 9 1 9 4 4 6 8 6 3 3 8 5 1 6 3 4 6 7 0 7 8 2 7 6 8 9 5 6 5 6 1 4 0 1 0 0 9 4 8 0 9 1 2 8 5 0 2 5 3 3
现在他想要从这个数组中寻找一些满足以下条件的子序列:
子序列的长度为8;
这个子序列可以按照下标顺序组成一个yyyymmdd 格式的日期,并且要求这个日期是2023 年中的某一天的日期,例如20230902,20231223。yyyy 表示年份,mm 表示月份,dd 表示天数,当月份或者天数的长度只有一位时需要一个前导零补充。
请你帮小蓝计算下按上述条件一共能找到多少个不同的2023 年的日期。
对于相同的日期你只需要统计一次即可。

枚举2023年的每一天进行子序列的匹配

#include<iostream>
#include<vector>
using namespace std;

bool daysmatch(vector<int>&numbers,vector<int>&match)
{
int idx=0;
for(int i=0;i<=99;i++)
{
if(numbers[i]==match[idx])
idx++;
if(idx==match.size())
return true;
}
return false;
}
int main(){
vector <int> numbers={5, 6, 8, 6, 9, 1, 6, 1, 2, 4, 9, 1, 9, 8, 2, 3, 6, 4, 7, 7, 5, 9, 5, 0, 3, 8, 7, 5, 8, 1, 5,
8, 6, 1, 8, 3, 0, 3, 7, 9, 2, 7, 0, 5, 8, 8, 5, 7, 0, 9, 9, 1, 9, 4, 4, 6, 8, 6, 3, 3, 8, 5,
1, 6, 3, 4, 6, 7, 0, 7, 8, 2, 7, 6, 8, 9, 5, 6, 5, 6, 1, 4, 0, 1, 0, 0, 9, 4, 8, 0, 9, 1, 2,
8, 5, 0, 2, 5, 3, 3};

int MonthDay[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int cnt=0;
for(int month=1;month<=12;month++)
{
for(int day=1;day<=MonthDay[month-1];day++)
{
vector <int> match={2,0,2,3,month/10,month%10,day/10,day%10};
cnt+=daysmatch(numbers,match);
}
}

cout<<cnt;
}