Being a good boy in Spring Festival
Time Limit: 1000MS |
|
Memory Limit: 32768KB |
|
64bit IO Format: %i64d &%i64u |
Submit Status
Description
A year away from parents are worried about
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?" ”
Input
The input data contains multiple test cases, each of which occupies 2 rows, and the first line contains an integer m (1<m<=100), which represents the number of stacks of poker, followed by a row 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 output his first feasible number of scenarios, otherwise please output 0, each instance output one row.
Sample Input
35 7 90
Sample Output
1 Test instructions title. The puzzle: The understanding of the nature of Nim's game is explored. If the initiator wins the difference or the value is not 0,
The first step of the tempo must have been through
changing the value of a number changes the XOR value of these numbers to 0. Assuming that there are n numbers, and that one of the numbers is a number to be reduced, then
the value of a must be greater than the XOR value of the number of n-1 except aBefore you can,
only greater than to pass A's reduction makes
The XOR value of all numbers is 0,If equal to that means that all the numbers of the difference or value is 0, the initiator will be defeated. If less then no matter how much less a can make a total difference or a value of 0, the binary representation must have at least one 1 exists.so iterate through each number to see which number is the one that meets the criteria just described, and how many of these are counted as the final result.
#include <iostream>using namespacestd;intMain () {intN; while(cin>>n&&N) {inta[ the],ans=0, cnt=0; for(intI=0; i<n;i++) {cin>>A[i]; Ans^=A[i]; } for(intI=0; i<n;i++) { if(A[i]> (Ans^a[i]))//Note parenthesescnt++; } //The following words do not understand also do not matter. In this code 1. You can remove the sentence of cout 0 by 2. You can add an equal sign when you are greater than your judgment .//But the two cannot be used at the same time because there is a number equal to the establishment then all the numbers equal to the cnt=n is the case that the difference or 0 of the initiator will fail//if both use the same time will be defeated output 0 of the situation into output n this is wrong, but alone with no problem if(ans) cout<<cnt<<Endl; Elsecout<<0<<Endl; } return 0;}
HDU1850 Being a good boy in Spring Festival (game)