neuqoj Code

Description

Roliygu is famous because he likes to play games. Today he puts a chessboard in the desktop,and plays a game with Yilan. The size of the chessboard is n by n. A stone is placed in a corner square. They play alternatively with Roliygu having the first move. Each time,player is allowed to move the stone to an unvisited neighbor square horizontally or vertically. The one who can’t make a move will lose the game. If both play perfectly, who will win the game?

Input

The input is a sequence of positive integers each in a separate line. The integers are between 1 and 10 000,inclusive,indicating the size of the chessboard. The end of the input is indicated by a zero.

Output

Output the winner(“Roliygu” or “Yilan”) for each input line except the last zero. No other characters should be inserted in the output.

This question is hard if we try to solve it just as the description of the question, however, we can change our mind to think about the question, can we get the result of who will win if we just know the odevity of the grid of the board and the upper-hand player? The anwser is YES!

Let’s look at the two pictures below:

if the grids’ number is even, if obvious that all of the grids and be divided into some pices of 1*2, what is very important for you to know is that the start point is in one grid, so the left grids’ number is actually odd, so you can know that who first, who win;

In the same way we can know that if the grids’ number is odd, the number except the start point will be even, so who later, who win;

So the question has been changed into Jugement of the odevity of the board’s grids number, it’s easy, isn’t it?

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n == 0)
{
break;
}

if(n * n % 2 == 0)
{
cout<<"Roliygu"<<endl;
}
else
{
cout<<"Yilan"<<endl;
}
}
}