Rabbit and Grass(杭电1849)(尼姆博弈)
Rabbit and Grass
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2254 Accepted Submission(s): 1704
说是下棋,事实上仅仅是一个简单的小游戏而已,游戏的规则是这种:
1、 棋盘包括1*n个方格,方格从左到右分别编号为0。1,2,…,n-1;
2、 m个棋子放在棋盘的方格上。方格能够为空,也能够放多于一个的棋子。
3、 两方轮流走棋;
4、 每一步能够选择随意一个棋子向左移动到随意的位置(能够多个棋子位于同一个方格),当然,不论什么棋子不能超出棋盘边界;
5、 假设全部的棋子都位于最左边(即编号为0的位置)。则游戏结束,而且规定最后走棋的一方为胜者。
对于本题,你不须要考虑n的大小(我们能够如果在初始状态,棋子总是位于棋盘的适当位置)。
以下的示意图即为一个1*15的棋盘。共同拥有6个棋子,当中,编号8的位置有两个棋子。
大家知道,尽管偶尔不够浪漫,可是Rabbit和Grass都是冰雪聪明的女生,假设每次都是Rabbit先走棋,请输出最后的结果。
2
3 5
3
3 5 6
0
Rabbit Win!
Grass Win!
#include<stdio.h>
int main()
{
int i,sum,n,t;
while(scanf("%d",&n)&&n>0)
{
for(i=0,sum=0;i<n;i++)
{
scanf("%d",&t);
sum^=t;
}
if(sum==0)
printf("Grass Win!\n");
else
printf("Rabbit Win!\n");
}
return 0;
}
Rabbit and Grass(杭电1849)(尼姆博弈)的更多相关文章
- hdu----(1849)Rabbit and Grass(简单的尼姆博弈)
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 1849(Rabbit and Grass) 尼姆博弈
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Being a Good Boy in Spring Festival(杭电1850)(尼姆博弈)
Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32 ...
- hdu 1849 (尼姆博弈)
http://acm.hdu.edu.cn/showproblem.php? pid=1849 简单的尼姆博弈: 代码例如以下: #include <iostream> #include ...
- Being a Good Boy in Spring Festival 尼姆博弈
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Descr ...
- HDU 4315 Climbing the Hill (阶梯博弈转尼姆博弈)
Climbing the Hill Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Su ...
- Light OJ 1393 Crazy Calendar (尼姆博弈)
C - Crazy Calendar Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Su ...
- LightOJ 1247 Matrix Game (尼姆博弈)
A - Matrix Game Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submi ...
- Light OJ 1253 Misere Nim (尼姆博弈(2))
LightOJ1253 :Misere Nim 时间限制:1000MS 内存限制:32768KByte 64位IO格式:%lld & %llu 描述 Alice and Bob ar ...
- hdu-------(1848)Fibonacci again and again(sg函数版的尼姆博弈)
Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
随机推荐
- Topo软件
http://jung.sourceforge.net/#! http://www.netdisco.org/ http://sourceforge.net/projects/toponet/ htt ...
- 克鲁斯卡尔(Kruskal)算法
# include <stdio.h> # define MAX_VERTEXES //最大顶点数 # define MAXEDGE //边集数组最大值 # define INFINITY ...
- 利用PowerDesigner15在win7系统下对MySQL 进行反向project(二)
利用PowerDesigner15在win7系统下对MySQL 进行反向project 1.打开PowerDesigner,建立新模型.选择Physical Data Model中的Physical ...
- 做ie8css样式时浏览器默认杂项模式遇到的一个小坑
1 进行ie浏览器的样式兼容的时候,首先要确保打开浏览器浏览网页的时候的文本模式要为当前浏览器的"标准模式",注意<!DOCTYPE html>不缺失不错误,以免浏览器 ...
- create a (VSTO) Office 2007 add-in using VS 2012?
You can get VS 2012 working with Office 2007. First create an Outlook 2010 Add-In and modify the pro ...
- ZOJ3784 String of Infinity 高大上的AC自动机 数据原来这么水啊!不算输入输出只有5-7行
找给定s集合里面word全部是同一个字符的,这样的word有几个,如果数量<m就yes,否则就no.#include<iostream> #include<cstring> ...
- -bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory
刚刚学习SHELL 写了一个简单的例子发生如下错误 -bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory ...
- trie tree(字典树)
hihocoder题目(http://hihocoder.com/problemset):#1014 trie树 #include <iostream> using namespace s ...
- OC语法1——OC概述
Object-C简介: OC,即Object-C,iOS开发的核心语言.它是基于C语言的,在C的基础上做了面向对象的封装,所以OC是面向对象的语言.同时也因此OC是兼容C的,也就是说在iOS开发中,可 ...
- Android Intent实现页面跳转
Intent可以来协助完成Android各个组件之间的通信 1:startActivity(intent); //直接启动 /* ...