标签:blog io for 2014 on log amp as file
BZOJ水一道~
枚举前两个位置是否放雷,模拟向下推,可以则ans++
#include "stdio.h" #include "string.h" int a[10010],b[10010],n; int judge() { int i; for (i=3;i<=n;i++) { b[i]=a[i-1]-b[i-1]-b[i-2]; if (b[i]<0) return 0; if (b[i]>1) return 0; } if (b[n-1]+b[n]!=a[n]) return 0; return 1; } int main() { int i,ans; while (scanf("%d",&n)!=EOF) { for (i=1;i<=n;i++) scanf("%d",&a[i]); if (a[1]>2) {printf("0\n");continue;} ans=0; for (i=0;i<=a[1];i++) { b[1]=i; b[2]=a[1]-b[1]; if (b[2]<=1 && judge()==1) ans++; } printf("%d\n",ans); } return 0; }
标签:blog io for 2014 on log amp as file
原文地址:http://blog.csdn.net/u011932355/article/details/40077959