Topic Links:
Checkerboard Issues
Base time limit: 1 seconds space limit: 131072 KB Score: 40
God created a n*m chessboard, each one of which could be black or white.
Adam and Eve were playing a game, each looking for a square with an X side, each of which must be black, and then dyed white.
If anyone can't operate, then that person loses.
Adam likes prime numbers.
Eve likes 1, but hates 2.
Therefore, they stipulate that x can be only 2 prime or 1.
Now they want to know who will win if they all play with the best strategy.
God rules Adam to be the initiator.
Sample explanation:
Here x can only be 1, so after 3 operations, Eve is unable to operate, Adam wins.
Input
The first line enters a T, which indicates that there are several sets of test data (1<=t<=10) next each data first row has two integers n,m (1<=n,m<=100) next n rows per row m number, if this number is 1, it means that position is black, otherwise white.
Output
For each set of data output "Yadang" or "Xiawa" (without quotation marks, indicating that the person will win).
Input example
12 31 1 00 0 1
Output example
Yadang
Test instructions
Ideas:
The equivalent of all the sunspots taken away, because only 2 of the prime number and 1 for the side of the square, so each take away is an odd number of pieces, the answer is to see the board on the odd number of or even a number of black pieces;
AC Code:
#include <bits/stdc++.h>/*#include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring > #include <algorithm> #include <cstdio>*/using namespacestd;#defineRiep (n) for (int i=1;i<=n;i++)#defineRIOP (n) for (int i=0;i<n;i++)#defineRJEP (n) for (int j=1;j<=n;j++)#defineRJOP (n) for (int j=0;j<n;j++)#defineMST (SS,B) memset (ss,b,sizeof (ss));typedefLong LongLL;ConstLL mod=1e9+7;Const DoublePi=acos (-1.0);ConstLL inf=1e18;Const intn=1e5+4;intn,m,a[ the][ the];intMain () {intT; scanf ("%d",&t); while(t--) {scanf ("%d%d",&n,&m); intsum=0; Riep (n) {Rjep (m) {scanf ("%d",&A[i][j]); Sum+=A[i][j]; } } if(sum%2) printf ("yadang\n"); Elseprintf"xiawa\n"); } return 0;}
51nod Checkerboard problem (game theory)