Reprinted please indicate the source, thank youHttp://blog.csdn.net/ACM_cxlove? Viewmode = Contents
By --- cxlove
Question: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3404
Select a rectangle to change the status of the Four Corner lights, and the light in the lower right corner must be enabled initially.
This kind of combined game problem lies inShen Niu Cao Qin Xiang's thesis: Starting from "K times dynamic subtraction game" to explore a class of combined game problems "said.
If there is only one line, that is, n = 0, each coin can be understood as a separate game, so the game seems to be the "and" of these separate games ", because the two coins can be understood as moving the front coin with a large coordinate to a small coordinate position. The only difference is that if you flip two front-up coins at the same time, it is equivalent to a coin with a small coordinate that is "eliminated" by a large coordinate. This is actually not in conflict with the game "and" model, because the SG function values of the two front coins in the same position must be the same, so their Nim
And 0, so it is equal to "NONE ".
Back to the original problem, it is clear that the problem also comes down to several separate games and several separate card-up coins. In a game that contains only one row, the SG function of a front-up coin is its column coordinate.
Each positive coin can be understood as an independent simple game, in which a simple game can be split into three game "and" In each operation ". This is the nesting of Game "and.
This is the analysis of this question. The operation and nature of Nim product are also detailed in this paper. Please refer
# Include <iostream> # include <cstdio> # include <cstring> # define n 2000000 using namespace STD; int M [2] [2] = {0, 0, 1 }; int nim_mult_power (int x, int y) {If (x <2) return M [x] [Y]; int A = 0; For (; A ++) if (x> = (1 <(1 <A) & x <(1 <(1 <(a + 1) break; int M = 1 <(1 <A); int P = x/m, S = y/m, t = Y % m; int d1 = nim_mult_power (p, s); int D2 = nim_mult_power (P, T); Return (M * (d1 ^ D2) ^ nim_mult_power (M/2, d1);} int nim_mult (int x, int y) {If (x <Y) return nim_mult (Y, x); If (x <2) return M [x] [Y]; int A = 0; for (; A ++) if (x> = (1 <(1 <)) & x <(1 <(1 <(a + 1) break; int M = 1 <(1 <); int P = x/m, q = x % m, S = y/m, t = Y % m; int C1 = nim_mult (P, S ), c2 = nim_mult (P, T) ^ nim_mult (Q, S), C3 = nim_mult (Q, T); Return (M * (C1 ^ C2 )) ^ C3 ^ nim_mult_power (M/2, C1);} int main () {int t, n, x, y; scanf ("% d", & T ); while (t --) {scanf ("% d", & N); int ret = 0; while (n --) {scanf ("% d", & X, & Y); RET ^ = nim_mult (x, y);} If (RET) puts ("have a try, lxhgww. "); elseputs (" Don't waste your time. ");} return 0 ;}