标签:第一个 can and span min str 题解 答案 scanf
//It is coded by Ning_Mew on 5.6
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+7;
int n,a[maxn];
int ans=0;
int ch[maxn];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
bool endd=true;
memset(ch,0,sizeof(ch));
ch[1]=1;
for(int i=2;i<=n;i++){
if(ch[i-1]+ch[i-2]==a[i-1])ch[i]=0;
else{
if(ch[i-1]+ch[i-2]==a[i-1]-1)ch[i]=1;
else {endd=false;break;}
}
}
if(endd&&ch[n-1]+ch[n]==a[n])ans++;
endd=true;
memset(ch,0,sizeof(ch));
ch[1]=0;
for(int i=2;i<=n;i++){
if(ch[i-1]+ch[i-2]==a[i-1])ch[i]=0;
else{
if(ch[i-1]+ch[i-2]==a[i-1]-1)ch[i]=1;
else {endd=false;break;}
}
}
if(endd&&ch[n-1]+ch[n]==a[n])ans++;
printf("%d\n",ans);
return 0;
}
【题解】 bzoj1088: [SCOI2005]扫雷Mine (神奇的做法)
标签:第一个 can and span min str 题解 答案 scanf
原文地址:https://www.cnblogs.com/Ning-Mew/p/9000000.html