Being a good boy in Spring Festival
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4658 Accepted Submission (s): 2781
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 Nim Game:
When the Nim game is somewhere: (X1,X2,X3), when and only if its parts are nim-sum = 0 (that is, x1⊕x2⊕x3 = 0 (that is, the XOR of each part is 0))
The current position is a fail point, which is also true for multiple heap scenarios.
That
There are three piles of various items, two people take turns from a heap of any number of items (or up to M, just put each heap%m), the provision of at least one at a time, more than open, and finally
The light winner wins.
a1^a2^a3^. ^an result is 0. Then the initiator will lose, otherwise it will win.
Example: 5 7 9
7^9 = 14
If you want to take the K, then if you want the result to be 0.
Then 5-k = k >=1 so must be 5 > 14 (not here). That's the number of that pile > other heaps of XOR and
1#include <iostream>2#include <cstring>3#include <cstdio>4#include <string>5 using namespacestd;6 #defineMAXN 10000107 intA[MAXN];8 intM;9 intMain () {Ten while(SCANF ("%d", &m) &&M) { One for(inti =1; I <= M; i++) scanf ("%d", &a[i]); A intsum = a[1]; - for(inti =2; I <= M; i++){ -sum^=A[i]; the } - if(Sum = =0) cout<<0<<Endl; - Else{ -sum =0; + intCNT =0; - for(inti =1; I <= M; i++){ +sum =0; A for(intj =1; J <= M; J + +){ at if(i = = j)Continue; - ElseSum ^=A[j]; - } - if(Sum < a[i]) cnt++; - } -cout<<cnt<<Endl; in } - } to + return 0; -}