Take the stone (vi)
Time limit: Ms | Memory Limit: 65535 KB
Difficulty: 3
Describe
Recently TopCoder Piaoyi and HRDV very boring, so he thought of a game, the game is like this: there are n heap of stones, two people take turns from one of the heaps of a certain stone, the last can not be taken as a loser, note: Each can only from a heap to take any one, you may take the heap, but not to take. Assuming that Piaoyi takes the stone first, ask you to help him decide if he can win (assuming they don't make mistakes in the process, they're smart enough).
Input
The first line is N, which represents the n set of test data (n<=10000)
Each of the following sets of test data contains two lines: The first line: Contains an integer m, representing the test data of this group have m (m<=1000) heap stone;
: The second line: contains the M integer Ai (ai<=100), which represents the number of stones in the I heap, respectively.
Output
If the Piaoyi wins the output "Piaoyi", otherwise output "HRDV" note that each group results in one row:
Sample input
3
2
1 1
3
3 8 11
2
5 10
Sample output
Hrdv
Hrdv
Piaoyi
Nim Games, note handling numbers with strings
//using strings to manipulate numbers saves time when the data is large//sum ^= n% (m+1);#include <stdio.h>#include<string.h>intMain () {intn,m,ans,a[ +]={0},i; Charch; scanf ("%d",&N); while(n--) {scanf ("%d",&m); Memset (A,0,sizeof(a)); Ans=0; GetChar (); for(i=0; i<m;i++) { while((Ch=getchar ()) >='0'&& CH <='9') A[i]=Ten*A[I] + CH-'0'; } for(i=0; i<m;i++) ans^=A[i]; if(ANS) printf ("%s\n","Piaoyi");//puts ("Piaoyi"); Elseprintf"%s\n","HRDV");//puts ("HRDV"); //printf ("%s\n", ans?) Piaoyi ":" HRDV "); } return 0;}
nyoj-take Stone (vi)