P1099
似乎是数据溢出了
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long A[10],DP[105][1][2][3][4][5][6][7][8];
int main(){
int n,m;
cin>>n>>m;
for(int i=0;i<m;i++)cin>>A[i];
DP[0][0][0][0][0][0][0][0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<m;j++){
for(int tp1=0;tp1<=0;tp1++){
for(int tp2=0;tp2<=1;tp2++){
for(int tp3=0;tp3<=2;tp3++){
for(int tp4=0;tp4<=3;tp4++){
for(int tp5=0;tp5<=4;tp5++){
for(int tp6=0;tp6<=5;tp6++){
for(int tp7=0;tp7<=6;tp7++){
for(int tp8=0;tp8<=7;tp8++){
int nn=DP[i-1][tp1][tp2][tp3][tp4][tp5][tp6][tp7][tp8];
if(A[j]==1 and tp1==0){
DP[i][A[j]-1][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]+=nn;
DP[i][A[j]-1][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]=DP[i][A[j]-1][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]%mod;
}
if(A[j]==2 and tp2==0){
DP[i][max(0,tp1-1)][A[j]-1][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]+=nn;
DP[i][max(0,tp1-1)][A[j]-1][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]=DP[i][max(0,tp1-1)][A[j]-1][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]%mod;
}
if(A[j]==3 and tp3==0){
DP[i][max(0,tp1-1)][max(0,tp2-1)][A[j]-1][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]+=nn;
DP[i][max(0,tp1-1)][max(0,tp2-1)][A[j]-1][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]+=DP[i][max(0,tp1-1)][max(0,tp2-1)][A[j]-1][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]%mod;
}
if(A[j]==4 and tp4==0){
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][A[j]-1][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]+=nn;
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][A[j]-1][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]=DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][A[j]-1][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]%mod;
}
if(A[j]==5 and tp5==0){
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][A[j]-1][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]+=nn;
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][A[j]-1][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]=DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][A[j]-1][max(0,tp6-1)][max(0,tp7-1)][max(0,tp8-1)]%mod;
}
if(A[j]==6 and tp6==0){
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][A[j]-1][max(0,tp7-1)][max(0,tp8-1)]+=nn;
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][A[j]-1][max(0,tp7-1)][max(0,tp8-1)]=DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][A[j]-1][max(0,tp7-1)][max(0,tp8-1)]%mod;
}
if(A[j]==7 and tp7==0){
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][A[j]-1][max(0,tp8-1)]+=nn;
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][A[j]-1][max(0,tp8-1)]=DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][A[j]-1][max(0,tp8-1)]%mod;
}
if(A[j]==8 and tp8==0){
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][A[j]-1]+=nn;
DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][A[j]-1]=DP[i][max(0,tp1-1)][max(0,tp2-1)][max(0,tp3-1)][max(0,tp4-1)][max(0,tp5-1)][max(0,tp6-1)][max(0,tp7-1)][A[j]-1]%mod;
}
}
}
}
}
}
}
}
}
}
}
long long ans=0;
for(int tp1=0;tp1<=0;tp1++){
for(int tp2=0;tp2<=1;tp2++){
for(int tp3=0;tp3<=2;tp3++){
for(int tp4=0;tp4<=3;tp4++){
for(int tp5=0;tp5<=4;tp5++){
for(int tp6=0;tp6<=5;tp6++){
for(int tp7=0;tp7<=6;tp7++){
for(int tp8=0;tp8<=7;tp8++){
ans+=DP[n][tp1][tp2][tp3][tp4][tp5][tp6][tp7][tp8];
ans=ans%mod;
}
}
}
}
}
}
}
}
cout<<ans<<endl;
}