shunfurh 于 2017.01.05 00:27 提问

Game

After played many kinds of nim games, Xay and Amr decided to play something different. As the judge, I wrote several valid pairs of numbers on the blackboard. For every pair (x, y), it is valid only if -y ≤ x ≤ y and the greatest common divisor of x and y is 1. The typical legal move is to alter just one of these pairs. If we change (x, y) to (a, b):
1. (a, b) should be a valid pair.
2. 1 ≤ b < y if y != 1
3. 1 ≤ b ≤ y, -b < a < b if y = 1.

Furthermore, such a replacement will be legal for Xay only if a*y – b*x < 0, legal for Amr only if a*y – b*x > 0.For example, Xay can change (2, 5) to (1,3), (1,4), (-1,2), (0,1), (-1,1), etc. And Amr can similarly change (2, 5) to (1, 2), (2, 3), (3, 4), (1, 1), etc.

They will play on these pairs alternately. The last one who be able to move is the winner .We have already knew that both Amr and Xay are very clever and they will play this game perfectly. Now, my dear programmers, can you predict that who will be the winner?

The first line contains a single positive integer T. which is the number of test cases. Each test case starts with a line with a single positive integer n(1 ≤ n ≤ 100) and a string “Xay” or “Amr” means who moves first. Then n lines follows, each line contains a pair of integers x and y. (1 ≤ y ≤ 15 and �y ≤ x ≤ y)

The first line contains a single positive integer T. which is the number of test cases. Each test case starts with a line with a single positive integer n(1 ≤ n ≤ 100) and a string “Xay” or “Amr” means who moves first. Then n lines follows, each line contains a pair of integers x and y. (1 ≤ y ≤ 15 and �y ≤ x ≤ y)

3
1 Xay
0 1
2 Amr
1 1
-1 1
2 Xay
1 4
-1 2

Amr
Xay
Amr

Hint

1个回答

caozhy      2017.01.12 00:47

Flip Game（状态压缩+BFS）
Link：http://poj.org/problem?id=1753 Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 32393   Accepted: 14147 Description Flip game
LeetCode- 289. Game of Life - 思路详解-C++

Jump Game II -- LeetCode

Game AI Pro 3 Collected Wisdom of Game AI Professionals 无水印pdf
Game AI Pro 3 Collected Wisdom of Game AI Professionals 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络，如有侵权，请联系上传者或csdn删除 本资源转载自网络，如有侵权，请联系上传者或csdn删除
[Game Engine]开源游戏框架（转至wiki）
﻿﻿   Agar - 一个高级图形应用程序框架，用于2D和3D游戏。Allegro - 基于 C/C++ 的游戏引擎，支持图形，声音，输入，游戏时钟，浮点，压缩文件以及GUI。Axiom 引擎 - OGRE的衍生引擎。Baja 引擎 - 专业品质的图像引擎，用于The Lost Mansion。Boom - Doom代码的一部分。由TeamTNT开发Bui
2D Game Kit 1--Get Started
Unity新出的2D Game Kit现在可以免费在Assets Store下载了，支持2017.3以上的版本。该2D游戏套件可实现快速开发2D游戏，不用编程。接下来是Unity官方关于2D Game Kit的教程。----------------------------------------------------------1.创建场景命名好后点击 Create会生成如下资源：里面包括背景，...
CRC.Game.AI.Pro.3.Collected.Wisdom.of.Game.AI.Professionals.2017
CRC.Game.AI.Pro.3.Collected.Wisdom.of.Game.AI.Professionals.2017
codeforces 936B Sleepy Game
http://www.elijahqi.win/2018/02/26/codeforces-936b-sleepy-game/ Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of n vertices and m edg...
Game Engine Architecture(中英两版本)

Game Engine Architecture 2nd Edition