提交传送门
这道题目就是找规律了,规律,规律!
这道题也就没森么好说的啦
贴个代码,大家早点Ak把。
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
int n,x[110000],f[110000],ans=0;
bool bk;
int pd(){
for(int i=2;i<n;i++){
int tmp=x[i]-f[i]-f[i-1];
if(tmp<0||tmp>1)return 0;
else f[i+1]=tmp;
}
if(f[n]+f[n-1]!=x[n])return 0;
return 1;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&x[i]);
memset(f,0,sizeof(f));
if(x[1]>2){printf("0\n");return 0;}
if(x[n]>2){printf("0\n");return 0;}
if(x[1]==0){
memset(f,0,sizeof(f));ans+=pd();
}
else if(x[1]==1){
memset(f,0,sizeof(f));
f[1]=1;ans+=pd();
memset(f,0,sizeof(f));
f[2]=1;ans+=pd();
}
else if(x[1]==2){
f[1]=1;f[2]=1;
ans+=pd();
}
printf("%d\n",ans);
return 0;
}