Being a good boy in Spring Festival |
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) |
Total submission (s): Wuyi Accepted Submission (s): 45 |
|
Problem Description a year outside parents time Spring Festival Home Can you do a few days good boy? Try to do the following things in winter vacation
Spend time with mom on the vegetable Quietly buy a little gift for dad Take the initiative to ask for a bowl wash once and for all One day get up early and give mom and dad a heart for breakfast.
You can talk to Mom and dad if you want. Let's play a little game. ACM Class to School ~
Here is a two-person mini-game: There are m stacks of poker on the table, and the number of cards per pile is ni (i=1 ... M); The two take turns, and each step can be arbitrarily selected and taken away from any of the cards; the poker on the table is all out, then the game is over; the last person to pick the card is the winner. Now we do not want to study whether to win or negative, I just want to ask you: -"If the initiator wants to win, the first step has several options?" ” |
The input data contains multiple test cases, each with 2 rows, and the first line contains an integer m (1<m<100), which represents the number of stacks of poker, followed by a line containing M-integers Ni (1<=ni<=1000000,i=1 ... m), representing the number of M-Heap poker, respectively. An M of 0 indicates the end of the input data. |
Output if the initiator can win, please export his first feasible number of scenarios, otherwise please output 0, the output of each instance takes up one row. |
Sample Input35 7 90 |
Sample Output1 |
Authorlcy |
SOURCEACM Short Term EXAM_2007/12/13 |
Recommendlcy |
/*Test Instructions: The initial idea of Nim's game: The game theorem of Nim knows that the current situation is the S-state when he is smart enough to be able to win, if the other side is smart enough to win, that is, 0 kinds, then how to judge the type of operation, when the first face of the S state of the time must want to leave the T state That is, to modify a heap of stones so that it can be n1^n2...^nn=0, so that x=n1^n2...^t^...^nn=0, if you want x equals zero, then modify one of the piles of NI, you would definitely like (NI ') ^ the remaining number XOR = 0, when NI is greater than the remaining number of different or , so it's possible to iterate through the array to find such a number.*/#include<bits/stdc++.h>using namespacestd;intN;inta[ the];intres=0;intCur=0;voidinit () {res=0; Cur=0;}intMain () { while(SCANF ("%d", &n)!=eof&&N) {init (); for(intI=0; i<n;i++) {scanf ("%d",&A[i]); Res^=A[i]; } for(intI=0; i<n;i++){ if(A[i]> (res^A[i])) Cur++; } if(res) printf ("%d\n", cur); ElsePuts"0"); } return 0;}
Being a good boy in Spring Festival (NIM game)