Being a good boy in Spring FestivalTime
limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 5157 Accepted Submission (s): 3092
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 Input
35 7 90
Sample Output
1
AuthorlcyCalculate the total number of scenarios, you can see Nimbo-Baidu EncyclopediaThe way to convert from a non-singular situation to a singular situation can be: 1) make a = C (+) b2) Make B = A (+) c3) Make C = A (+) b
expansion: to give n heap of stones, the two take turns from any heap of any (can only be taken from a pile), the last one to win the stone, ask how to take the first person how to win?
According to the above, the n number is different or can be. If the beginning of the t=0, then the first to take the loser , if the beginning of t>0, then as long as each time to remove the stone to make t=0, that is, the first to win the method.
We assume that a pebble is taken from the first heap, and we only need to vary the number of stones in all the heaps except for the heap I, temp=a[1]^a[2]^....^a[i-1]^a[i+1]^ ... A[n], to make the first person to win the stone, the first person so long as the number of stones in the heap is temp, for us, as long as we judge the size of temp and a[i], if temp>a[i], then can not make a[i] Also cannot reach the temp stone number, if is less than, then can ~ ~ Unexpectedly did not have 1 A,, I have been stupid to cry to see the code:
#include <stdio.h> #define MAX 110int Main () {int m; ~scanf ("%d", &m) && m) {int N[max], t = 0;for (in t i = 0; I < m; ++i) {scanf ("%d", &n[i]); if (i = = 0) {t = n[i];} Else{t = T^n[i];}} if (t = = 0) {puts ("0"); continue;} int temp =-1, ans = 0, for (int i = 0; i < m; ++i) {temp =-1; for (int j = 0; j < m; ++j) {if (i! = j) {if (temp = = -1) {temp = n[j];} Else{temp = Temp^n[j];}} if (Temp<n[i]) {ans++;}} printf ("%d\n", ans);} return 0;}
with June
Hdu 1850 Being A good boy in Spring Festival game theory of Nim game, all by their own stupid cry!