Rabbit and GrassTime
limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 2507 Accepted Submission (s): 1888
Problem Description University time is romantic, the girls are romantic, Christmas is more romantic, but rabbit and grass the two college girls in this year's Christmas is not a bit romantic: not to go shopping malls, not to go to the park, not to and AC male dating, Two people even the cat is playing chess ...
Said to be chess, in fact, is just a simple little game, the rules of the game is this:
1, the chessboard contains 1*n, squares from left to right respectively numbered as 0,1,2,...,n-1;
2, M pieces on the chessboard on the grid, squares can be empty, can also put more than one piece;
3, the two sides take turns moves;
4, each step can choose any one of the pieces to move to the left to any position (can be multiple pieces in the same square), of course, any pieces can not exceed the board boundaries;
5. If all the pieces are on the leftmost (i.e. numbered 0), the game is over and the final moves is specified as the winner.
For the subject, you do not need to consider the size of N (we can assume that in the initial state, the pawn is always in the appropriate position on the board). The following is a 1*15 board, a total of 6 pieces, of which the number 8 position has two pieces.
You know, although occasionally not romantic, but rabbit and grass are clever girls, if every time is rabbit first moves, please output the final result.
Input data contains multiple sets of test cases, each of which occupies two rows, and the first line contains an integer m (0<=m<=1000), representing the number of pieces of this test case, followed by a row containing M integers Ki (i=1...m; 0<=ki<=1000) , which represents the initial position of the m pieces, and m=0 the input at the end.
Output if Rabbit can win, please export "Rabbit win!", otherwise output "Grass win!", the output of each instance takes up one row.
Sample Input
2 3 533) 5 60
Sample Output
Rabbit win! Grass win!
Authorlcy Simple NIM Game ~
#include <stdio.h>int main () {int m; while (~SCANF ("%d", &m) && m) {int-ans = 0; for (int i = 0; i < m; ++i) {int t; scanf ("%d", &t); ans ^= t;} if (ans = = 0) {puts ("Grass win!");} Else{puts ("Rabbit win!");}} return 0;}
with June
Hdu 1849 Rabbit and Grass who all like to brush water questions. The game of Nim