Nim game: Being a good boy in Spring Festival

Source: Internet
Author: User

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

1#include <cstdio>2#include <iostream>3#include <cstring>4#include <string>5#include <algorithm>6 7 using namespacestd;8 9 Const intMAX = the;Ten  One intArr[max], Xorarr[max]; A  - intMain () - { the #ifdef OFFLINE -Freopen ("In.txt","R", stdin); -Freopen ("OUT.txt","W", stdout); - #endif +  -     intm; +      while(~SCANF ("%d", &m) &&m) A     { atmemset (arr,0,sizeof(arr)); -memset (Xorarr,0,sizeof(Xorarr)); -  -          for(inti =0; I < m; i++) -scanf"%d", &arr[i]); -  in         intAns =0; -          for(inti =0; I < m; i++) toAns ^=Arr[i]; +  -         if(!ans) the         { *printf"0\n"); $             Continue;Panax Notoginseng         } -  theAns =0; +          for(inti =0; I < m; i++) A         { the             intTMP =0; +              for(intj =0; J < M; J + +) -             { $                 if(I! =j) $TMP ^=Arr[j]; -             } -  the             if(TMP <=Arr[i]) -ans++;Wuyi         } the  -printf"%d\n", ans); Wu     } -  About     return 0; $}
View Code

Nim game: Being a good boy in Spring Festival

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.