/* It is just a binary counter, counting down from an initial pattern */ /* The initial pattern is the answer, but what if they don't realize? */ #include #include #include #include typedef long long ll; // return 0 if no more ocelots int bell(char *critters,int N) { //find lowest ocelot char *begin; if((begin = strchr(critters,'O')) == NULL) return 0; *(begin--) = 'Z'; while(begin >= critters) *(begin--) = 'O'; return 1; } void printstr(char *critters,int N) { do{ printf("%c",critters[N--]); }while(N>=0); printf("\n"); } int main() { ll bits = 0; ll mask; int N,i; // ocelots are 1, zebras are 0 int line = 0; int ch; ll count=0; char *critters; if(scanf("%d",&N)!=1) { perror("error reading N:"); exit(1); } ++line; critters = malloc(sizeof(char)*(N+1)); for(i=0;i