Being a good boy in Spring FestivalTime
limit:MS
Memory Limit:32768KB
64bit IO Format:%i64d &%i64u SubmitStatusPracticeHDU 1850Appoint Description:System Crawler (2015-03-07)
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
Sample Output
Flying God to the weak topic, instant skills to add body, quickly get.
This problem, if different or after the sum value ==0, then the initiator will be defeated, that is, 0 kinds of possible, if not equal to zero, in the priority state, the initiator will win, then exactly how many kinds of situation? This is used in the different or operation of the formula, A^b^a=b. That is, after you have finished to let the hand for the initiator is out of the state, X to remove the rest of the current a[i] a[i] or value, want to lose, then x^a[i]==0, that is x==a[i], so you just find x<a[i] , you will be able to guarantee that you will lose your hand before you take it.
#include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include < iostream> #include <algorithm> #include <set> #include <queue> #include <map>typedef long Long ll;using namespace Std; LL A[110];int Main () { int n,i; while (~SCANF ("%d", &n)} { if (!n) break; for (i=0;i<n;i++) scanf ("%lld", &a[i]); LL sum=0; for (i=0;i<n;i++) { sum^=a[i]; } if (sum==0) { printf ("0\n"); } else{ int cnt=0; for (i=0;i<n;i++) { int x=sum^a[i]; if (X<a[i]) cnt++; } printf ("%d\n", CNT); } } return 0;}
HDU 1850-being a good boy in Spring Festival (NIM game)