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后者胜,否则先者胜。
- neuq oj 1016 Roliygu and Yilan C++
- neuq oj 1010 阶乘数列 C语言
- neuq oj 1034: C基础-求同存异 C++
- neuq oj 1018 A+B again C语言
- neuq oj 1051: 谭浩强C语言(第三版)习题6.7
- NEUQ OJ 1039: 谭浩强C语言(第三版)习题4.9
- neuq-oj-1042
- NEUQ oj 1036 题解
- NEUQ oj 1068 题解
- neuq oj 1007 计负均正 C++
- NEUQ oj-1317手机键盘
- NEUQ oj-1102高级机密
- NEUQ-OJ:1177 亲和数
- neuq oj 1038: 谭浩强C语言(第三版)习题4.8 C语言
- neuq oj 1043: 谭浩强C语言(第三版)习题5.7 C语言
- neuq oj 1049: 谭浩强C语言(第三版)习题6.5 C语言
- neuq oj 1052: 谭浩强C语言(第三版)习题6.8 C语言
- neuq oj 1053: 谭浩强C语言(第三版)习题6.9 C语言
- 美团、58、百度、阿里面经
- Java多线程通过多核CPU来提升速度--更快的执行
- [剑指offer-1518]反转链表
- JAVA的BigInteger
- 解决win10下WIFI无法连接到网络
- neuq oj 1016 Roliygu and Yilan C++
- 排序算法笔记_____2(选择排序和插入排序)
- swift算法手记-10
- 最大二分匹配
- 微信支付之HTML5页面WAP端接入
- Educational Codeforces Round 7 A. Infinite Sequence
- 冒泡 随机数
- Educational Codeforces Round 7 B. The Time
- 开发web面试