Http://acm.fafu.edu.cn/problem.php? Id = 1292
The prototype of this question is the stone removal game c introduced in this paper, "from perceptual knowledge to rational understanding-the process of solving a kind of Combat Games ".
A and B face several stones, and the number of stones in each row can be determined at will. Example 2 shows the initial situation: n = 3 rows in total, where a1 = 7 in the first row, a2 = 3 in the second row, and A3 = 3 in the third row. The two take turns to take some stones according to the following rules. The rules of the game are as follows:
2 stones must be removed from a row in each step;
The two stones must be closely tied;
Who is the loser if no one can take the child according to the rule.
The following code is provided:
# Include <cstdio> # include <cstring> using namespace STD; int SG [101]; bool me [101]; void getsg () {for (INT I = 0; I <= 100; ++ I) {memset (Me, 1, sizeof (me); For (Int J = 0; j <= (I-2)> 1); ++ J) me [SG [J] ^ SG [i-2-j] = 0; For (Int J = 0; j <= 100; ++ J) {If (me [J]) {SG [I] = J; break ;}}} int main () {int N, A; getsg (); While (~ Scanf ("% d", & N) {int res = 0; For (INT I = 0; I <n; ++ I) {scanf ("% d ", & A); Res ^ = SG [a];} If (RES) puts ("gabo"); else puts ("Tang");} return 0 ;}
[Fafu 1292] Game Theory, combined games, and stone removal games