题目描述
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?
Roliygu 因喜欢玩游戏而出名。今天,他把棋盘放在桌面上,和Yilan下棋。棋盘的大小是 n x 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 和 10000 之间(含 10000),表示棋盘的大小。输入的末尾用零表示。
输出描述
Output the winner("Roliygu" or "Yilan") for each input line except the last zero. No other characters should be inserted in the output.
输出除最后一个零之外的每个输入行的winner(“Roliygu”或“Yilan”)。不应在输出中插入其他字符。
样例输入
2
0
样例输出
Roliygu
#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
while(n!=0){
if(n%2==0){
printf("Roliygu\n");
}
else{printf("Yilan\n");}
scanf("%d",&n);
}
return 0;
}
首先(n*n)-1即可以移动的次数。因为双方打得很完美,所以有次数时就能移动。次数为奇数时,Roliygu获胜。次数为偶数时,Yilan获胜。由此可知,n为偶数时Roliygu获胜。