A Simple Game

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)
Total Submission(s): 1487    Accepted Submission(s): 939

Problem Description
Agrael likes play a simple game with his friend Animal during the classes. In this Game there are n piles of stones numbered from 1 to n, the 1st pile has M1 stones, the 2nd pile has M2 stones, ... and the n-th pile contain Mn stones. Agrael and Animal take turns to move and in each move each of the players can take at most L1stones from the 1st pile or take at most L2 stones from the 2nd pile or ... or take Ln stones from the n-th pile. The player who takes the last stone wins.

After Agrael and Animal have played the game for months, the teacher finally got angry and decided to punish them. But when he knows the rule of the game, he is so interested in this game that he asks Agrael to play the game with him and if Agrael wins, he won't be punished, can Agrael win the game if the teacher and Agrael both take the best move in their turn?

The teacher always moves first(-_-), and in each turn a player must takes at least 1 stones and they can't take stones from more than one piles.

 
Input
The first line contains the number of test cases. Each test cases begin with the number n (n ≤ 10), represent there are n piles. Then there are n lines follows, the i-th line contains two numbers Mi and Li (20 ≥ Mi > 0, 20 ≥ Li > 0). 
 
Output
Your program output one line per case, if Agrael can win the game print "Yes", else print "No". 
 
Sample Input
2
1
5 4
2
1 1
2 2
 
Sample Output
Yes
No
 
Author
Agreal@TJU
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  1852 1854 1858 1730 1857 
 
简单的SG函数题,结果为每个子游戏的sg值的异或,每个子游戏都是简单的巴什博弈
 #include<stdio.h>
int main()
{
int t,n,m,l;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int sg=;
for(int i=;i<n;i++){
scanf("%d%d",&m,&l);
sg ^= m%(l+);
}
if(sg)
puts("No");
else
puts("Yes");
}
return ;
}
 

hdu 1851(A Simple Game)(sg博弈)的更多相关文章

  1. HDU 5795 A Simple Nim (博弈 打表找规律)

    A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...

  2. HDU 1851 A Simple Game

    典型的尼姆博弈,在n对石子中,告诉你每堆的数目和每次从该堆最多可以取的数目,求最终谁将其取完. 题解:SG(i)=mi%(li+1),求异或值即可. #include <cstdio> i ...

  3. hdu 1851 尼姆+巴什博弈

    先在每堆中进行巴什博弈,然后尼姆 #include<stdio.h> int main() { int T; int i,n; int ans,m,l; scanf("%d&qu ...

  4. hdu 1851 A Simple Game 博弈论

    简单博弈问题(巴什博弈-Bash Game) 巴什博弈:只有一堆n个物品,两个人轮流从这对物品中取物,规定每次至少取一个,最多取m个,最后取光着得胜. 很容易想到当n%(m+1)!=0时,先取者必胜, ...

  5. HDU 1851 (N个BASH博弈子游戏)

    题意:n堆石子,分别有M1,M2,·······,Mn个石子,各堆分别最多取L1,L2,·····Ln个石头,两个人分别取,一次只能从一堆中取,取走最后一个石子的人获胜.后选的人获胜输出Yes,否则输 ...

  6. HDU 1848(sg博弈) Fibonacci again and again

    Fibonacci again and again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  7. HDU 5795 A Simple Nim(简单Nim)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  8. HDU 5794 - A Simple Chess

    HDU 5794 - A Simple Chess题意: 马(象棋)初始位置在(1,1), 现在要走到(n,m), 问有几种走法 棋盘上有r个障碍物, 该位置不能走, 并规定只能走右下方 数据范围: ...

  9. HDU 4974 A simple water problem(贪心)

    HDU 4974 A simple water problem pid=4974" target="_blank" style="">题目链接 ...

  10. hdu 4972 A simple dynamic programming problem(高效)

    pid=4972" target="_blank" style="">题目链接:hdu 4972 A simple dynamic progra ...

随机推荐

  1. 【CF613D】Kingdom and its Cities(虚树,动态规划)

    [CF613D]Kingdom and its Cities(虚树,动态规划) 题面 洛谷 CF 翻译洛谷上有啦 题解 每次构建虚树,首先特判无解,也就是关键点中存在父子关系. 考虑\(dp\),设\ ...

  2. 北京Uber优步司机奖励政策(4月1日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  3. [python]PyCharm安装与激活

    一.安装 1.去官网下载安装包(http://www.jetbrains.com/pycharm/download/#section=windows) 2.下载完成之后双击即可点击安装,按照自己需求选 ...

  4. 在线大数据cdh迁移,从公有云迁移到私有云

    1.添加新节点 2.迁移hdfs和hbase数据: 3.迁移源节点各个服务到新节点: 4.利用HA,包括hdfs,hbase master,resourcemanager的ha实现在线迁移: 5.数据 ...

  5. 深入解析UUID及其应用(转载)

    UUID 编辑 UUID含义是通用唯一识别码 (Universally Unique Identifier),这 是一个软件建构的标准,也是被开源软件基金会 (Open Software Founda ...

  6. 获取附加在方法上的Attribute

    如下: class Program { static void Main(string[] args) { var methodInfo = typeof(Program).GetMethod(&qu ...

  7. Python3.6+selenium3.8+Firefox5.7 环境搭建

    大家好,我是阿哲,本人是从php转岗过来学习测试的一名小菜! 在学习selenium过程中,发现运行selenium有很多的问题. 我们在利用pip install selenium 安装的最新版后, ...

  8. 使用advanced_installer将.net web程序打包为安装程序

    当项目开发完成之后,需要给客户使用时,总不能将发布后的文件全部放一起压缩后直接给客户吧,然后客户需要自行搭建环境修改配置等等,体验太差了,这时候我们就需要使用一种打包工具了,查了一些资料之后,我选择使 ...

  9. mysql新手进阶03

    当年忠贞为国酬,何曾怕断头? 如今天下红遍,江山靠谁守? 业未就,身躯倦,鬓已秋. 你我之辈,忍将夙愿,付与东流? 数据库结构如下: 仓库(仓库号, 城市, 面积) 订购单(职工号, 供应商号, 订购 ...

  10. [JSON].valueOf( keyPath )

    语法:[JSON].valueOf( keyPath ) 返回:[任意类型 | null] 说明:获取键名路径原值,它保留原始值的类型 示例: b = sysFile.binary("tes ...