编程介的小学生 2017-01-04 16:27 采纳率: 20.5%
浏览 916
已采纳

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条回答

  • threenewbee 2017-01-11 16:47
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决