neuq oj 1016 Roliygu and Yilan C++

来源:互联网 发布:linux下解压rpm文件 编辑:程序博客网 时间:2024/06/04 19:07

1016: Roliygu and Yilan

时间限制: 1 Sec  内存限制: 128 MB
提交: 73  解决: 40
[提交][状态][讨论版]

题目描述

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?

棋盘大小为n*n,棋子置于棋盘一角,Roliygu先走,每次玩家允许沿水平或竖直方向邻近方格走一格,无法移动者失败。

输入

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.

输入为介于1—1000的正整数。输出以0为结束标志。

输出

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


样例输入

20

样例输出

Roliygu

提示

染色问题

代码

#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n&&n!=0)
{
if((n*n-1)%2==0)
{
cout<<"Yilan"<<endl;
}

else

{
cout<<"Roliygu"<<endl;
}
    }
return 0;
}

体会:

找规律:(n*n-1)%2==0后者胜,否则先者胜。

0 0
原创粉丝点击