标签:cst turn logs else can color style int clu
DFS即可过~
#include <cstdio> #include <algorithm> #include <cstring> int Map[10005],n,ban[10005],tot; void dfs(int h){ if(h>n){ if(Map[h-1]+Map[h-2]==ban[h-1]) tot++; return; } if(h==1){ dfs(h+1); Map[h]=1; dfs(h+1); Map[h]=0; } else if(Map[h-1]+Map[h-2]==ban[h-1]){ dfs(h+1); } else if(Map[h-1]+Map[h-2]+1==ban[h-1]){ Map[h]=1; dfs(h+1); Map[h]=0; } else if(Map[h-1]+Map[h-2]+1 < ban[h-1] || Map[h-1]+Map[h-2]+1 > ban[h-1]) return; } int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&ban[i]); dfs(1); printf("%d\n",tot); return 0; }
标签:cst turn logs else can color style int clu
原文地址:http://www.cnblogs.com/OIerLYF/p/7496027.html