Consider all the elements of M in each row as a bunch, and turn the problem into N-Heap Nim games.
Then preprocessing the number of each number of factors within 10000, and then according to the Bouton theorem in the book, calculate the N-line factor because of the number of different or and.
0 is the initiator must lose the situation, output no, otherwise output yes
1#include <cstdio>2#include <cmath>3 4 Const intMAXP =10000;5 intF[maxp +Ten];6 7 intMain ()8 {9 //freopen ("In.txt", "R", stdin);Ten One for(inti =2; I <= Maxp; i++)if(!F[i]) A { - intt =i; - while(T <=Maxp) the { - for(intj = t; J <= Maxp; J + = t) f[j]++; -T *=i; - } + } - + intT; Ascanf"%d", &T); at for(intKase =1; Kase <= T; ++Kase) - { - intN, M; -scanf"%d%d", &n, &m); - intXorsum =0; - for(inti =0; I < n; i++) in { - intCNT =0; to for(intj =0; J < M; J + +) + { - intx; thescanf"%d", &x); *CNT + =F[x]; $ }Panax NotoginsengXorsum ^=CNT; - } theprintf"Case #%d:%s\n", Kase, Xorsum?"YES":"NO"); + } A the return 0; +}
code June
UVa 11859 (Nim) Division Game