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 acorner 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 indicatedby 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后者胜,否则先者胜。
相关文章推荐
- Chapter 1-03
- neuq oj 1015同因查找C++
- C++11 转移语义 (Move Sementics) 和精确传递 (Perfect Forwarding)
- C语言连接mysql数据库查询中文的数据表乱码问题
- C语言的一些小知识
- C语言 实现base64
- C语言 实现base64
- c语言中结构,动态分配内存的理解
- C语言连接mysql简单查询实例入门-mysql_init,mysql_real_connect,mysql_query,mysql_close等
- C++中vector的实现
- 北电C语言笔试题(1)
- neuq oj1014 等差数列C++
- neuq oj 1013 求偶数和 C++
- bzoj3110 K大数查询
- [c++] 友元详解
- 使用C语言编写程序,求解有一分数序列:2/1,3/2,5/3,8/5,13/8,21/13...求出这个序列的前20项
- 【CCF】201312-3 最大矩形
- 【C语言】C语言函数
- 【C语言】C语言函数
- C语言高级测试:为C程序员准备的16个最佳问题