您的位置:首页 > 编程语言 > C语言/C++

neuq oj 1016 Roliygu and Yilan C++

2016-02-11 19:53 363 查看


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.


样例输入

2
0


样例输出

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后者胜,否则先者胜。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: