nyoj-take Stone (vi)

Source: Internet
Author: User

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)

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.