/* ID: ******** PROG: checker LANG: C (USACO Gate) Checker Challenge Done by Teh Ming Han */ /* Algorithm: Recursion Notes: If n is even, we can compute half a board and then flip along the x axis to generate the other half of the board. this means we only need to generate half the board if n is even. If n is odd, we compute half a board and then (half + 1 rows) of the board. Then we sum then up to get the answer. */ #include #include //#include int ans[3][14] = {0}, ans_c = 0; int board[14] = {0}, n, size; int recur(int r){ if (r==size){ //jackpot if (ans_c<3) memcpy(ans[ans_c],board,sizeof(int)*size); ans_c++; return 0; } int a; char cans[28] = {'#'}; for (a=1;a6) ans_c *= 2; else if (n%2==1 && n>6) ans_c = ans_c + ans_temp; FILE *out = fopen ("checker.out", "w"); for (i=0;i<3;i++){ for (a=1;a